1.

Can you think of a difference between an array of strings and other two-dimensional arrays? What is it? Support your answer with examples.

Answer»
Array of stringsTwo-dimensional array
Array of string is used to store string value.Two-dimensional array is used to store numeric value.
The first index determines the number of strings and the second index determines maximum length of each string.The first index determines the number of rows and the second index determines maximum columns of each string.
Example:
int a[2][3];
int i,j;
for(i=0;i<2;i++)
{
for(j=0;j<3;++j)
{
cout<<"Enter element:";
cin>>a[i][j];
}
}
Example:
char string[3][31];
int i;
cout<<"Enter 3 strings:"; for(i=0;i<3;i++)
cin.getline(string[i],31);


Discussion

No Comment Found

Related InterviewSolutions