String / Character array
#include<iostream.h>
void main()
{
int i,j;
char name[5][20];
char namex[20];
//input data
cout<<"Input data\n";
for(i=0;i<5;i++)
{
cout<<"Enter name "<< i+1<<" : ";
cin>>namex;
for(j=0;j<20;j++)
name[i][j]=namex[j];
}
cout<<"\nOutput data\n";
for(i=0;i<5;i++)
cout<<"Name of "<< i+1<<" is : "<<name[i]<<endl;
}
//coded in c++ by Radian B. Sena for educational purpose only
Comments
Post a Comment