Search This Blog

Thursday, October 13, 2011

Write a program that will read names of three students from the keyboard store them as array of strings

   1:  #include<stdio.h>
   2:  #include<conio.h>
   3:  #include<string.h>
   4:  void main()
   5:  {
   6:  int i;
   7:  char sname[3][40];
   8:  char yourname[40];
   9:  for(i=0;i<3;i++)
  10:      {
  11:      printf("Enter the name of the student:\n");
  12:      gets(yourname);
  13:      strcpy(sname[i],yourname);
  14:      }
  15:  for(i=0;i<3;i++)
  16:  puts(sname[i]);
  17:  getch();
  18:  }

No comments:

Post a Comment