Array of string
#include <stdio.h>
int main()
{
char name[] = "rohit";
char name2[] = {'r','a','m' , '\0'};
char names[][15] = {
"animesh",
"bhanu",
"chintu",
"dheeraj",
"elvish"
};
printf("%s is the 1st name\n" , names[0]);
printf("%c is the 2nd charater of 2nd name\n" , names[1][1]);
return 0;
}
**************
//If we want input from other then
#include <stdio.h>
int main()
{
char name[] = "rohit";
char name2[] = {'r','a','m' , '\0'};
char names[5][15];
int counter;
for (counter =0 ; counter < 5 ; counter++){
printf("enter the name of %d person\n" , counter+1);
scanf("%s", names[counter]);
}
for (counter =0 ; counter < 5 ; counter++){
printf(" the name of %d person is %s\n" , counter+1, names[counter] );
}
return 0;
}
Comments
Post a Comment