title: How to print entered string using for loop?
body: <p>I am new to C Programming ,I don't know what can I change in this code if I compile this code it displays only last name only for n times .. Why it won't display other names please help experts .. Thank you!</p>
  
  <pre><code>#include&lt;stdio.h&gt;
  #include&lt;string.h&gt;
  #include&lt;malloc.h&gt;
  int main()
  {
      int a;
      char n[50];
      printf("enter the number of students:\n");
      scanf("%d",&amp;a);
      printf("enter the names of the students\n");
      int i;
      for(i=0;i&lt;a;i++)
      {
          scanf("%s",n);
      }
  
      for(i=0;i&lt;a;i++)
      {       
  
          printf("%s\n",n);
  
      }
  
  return 0;
  
  }
  </code></pre>