Double dimension character array
char n[20]: one string of size 20(19+1)
char n[10][20]: 10 strings each of size 20(19+1).
Question:1
C program to take input for 5 names and display them.
Sol:
#include<stdio.h> int main() { char n[5][20]; int i; /* clrscr(); */ /* input */ for(i=0;i<5;i++) { printf("Enter any name "); gets(n[i]); } /* display */ for(i=0;i<5;i++) { printf("%s\n",n[i]); } getch(); return(0); }
/* Output */ Enter any name Amit Enter any name Sumit Enter any name Kapil Enter any name Mohan Enter any name Madan Amit Sumit Kapil Mohan Madan