C Program For Array of Structures

Get Certified in C Programming and Take Your Skills to the Next Level

Program 1

// Program for Array of Structure in C
#include<stdio.h>
#include<conio.h>
#include<string.h>
// Structure
struct Student
{
    int rno;                   //  Member variable of Structure 
    char name[50];      //  Member variable of Structure  , Array in structure
    double per;               //  Member variable of Structure 
};struct Student S[5];   // Structure type of variable , Array of structre
void main()
{
    int i;
    fflush(0);
    for(i=0;i<5;i++)
   { 
    printf("\nEnter Roll No : ");
    scanf("%d",&S[i].rno);
    fflush(0);
    printf("\nEnter Name : ");
    scanf("%s",S[i].name);
    printf("\nEnter Percentage : ");
    scanf("%lf",&S[i].per);
   }

    printf("\n-------------Student Infromation---------------\n\n");
    printf("\nRoll No\t Name\t Percentage\n");
    for(i=0;i<5;i++)
   { 
    printf("%d",S[i].rno);
    printf("\t%s",S[i].name);
    printf("\t %.2lf",S[i].per);
    printf("\n");
   }
}

 

Did you know we work 24x7 to provide you best tutorials
Please encourage us - write a review on Google

courses

TechVidvan Team

TechVidvan Team provides high-quality content & courses on AI, ML, Data Science, Data Engineering, Data Analytics, programming, Python, DSA, Android, Flutter, full stack web dev, MERN, and many latest technology.

Leave a Reply

Your email address will not be published. Required fields are marked *