title: Weird issue with Output in C
body: <pre><code>#include &lt;stdio.h&gt;
  
  struct agent
  {
      char name[30];
      int  age;
  } list[20];
  
  main()
  {
      struct agent getData();
      char         ch;
      int          i = 0;
      int          j;
  
      puts("1. Enter More");
      puts("2. Display");
      puts("3. Exit");
  
      while ((ch = getchar()) &lt; '3')
      {
          if (ch == '1')
          {
              list[i++] = getData();
          }
          else if (ch == '2')
          {
              for (j = 0; j &lt; i; j++)
              {
                  puts(list[j].name);
                  printf("%d\n", list[j].age);
              }
          }
  
          puts("1. Enter More");
          puts("2. Display");
          puts("3. Exit");
      }
  }
  
  struct agent getData(
  {
      struct agent tmp;
  
      puts("Enter name");
      scanf(" %s",tmp.name);
      puts("Enter age");
      scanf("%d",&amp;tmp.age);
  
      return tmp;
  }
  </code></pre>
  
  <p>OUTPUT:</p>
  
  <pre><code>1. Enter More
  2. Display
  3. Exit
  1
  Enter name
  ace
  Enter age
  23
  1. Enter More
  2. Display
  3. Exit
  1. Enter More
  2. Display
  3. Exit
  3
  </code></pre>
  
  <p>why are these statements 
  "1. Enter More
  2. Display
  3. Exit "
  getting repeated??</p>