Program to accept and display details of 5 students (roll no, name, percentage) using structure

C File =>



/* Write a program to accept and display details of 5 students (roll no, name, percentage) using structure. */


#include<stdio.h>
#include<stdlib.h>
typedef struct Student
{
   int rno;
   char name[50];
   float perc;
};


int main() {
      struct Student s[5];
      int i;
      for(i=0;i<5;i++)
     {
          printf("\n\n Enter Roll no. : ");
          scanf("%d",&s[i].rno);
          printf("\n Enter Name : ");
          scanf("%s",s[i].name);
          printf("\n Enter percentage : ");
          scanf("%f",&s[i].perc);
      }
      printf("\n\n Given details are : ");
      for(i=0;i<5;i++) 

     {
          printf("\n \n Roll number : %d\n",s[i].rno);

          printf("Name : %s \n",s[i].name);

          printf(" Percentage : %f",s[i].perc); 

      }
return 0;
}

Comments

Popular posts from this blog

Write a program to allocate memory dynamically for n integers. Accept the elements and calculate their sum and average

C program to accept names of n cities and search for city named “Pune”.