Program to Input multiple values in Structure using loop

#include<stdio.h>
#include<conio.h>
struct stu
{
int roll;
char name[50];
}k[2];
void main()
{
int i;
clrscr();
for(i=0;i<2;i++)
  {
  printf("\nEnter Roll");
  scanf("%d",&k[i].roll);
  printf("\nEnter Name");
  scanf("%s",&k[i].name);
  }
  for(i=0;i<2;i++)
    {
    printf("\n%d %s",k[i].roll,k[i].name);
    }

  getch();
}

Leave a Reply