Structures in C Programming

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

Program 1

// Program for Structure
#include<stdio.h>
#include<conio.h>
#include<stdlib.h>
#include<string.h>
struct Student
{
    int rno;
    char name[50];
    float per;  
}; struct Student s[5];  // Array of Structure
int main()
{
    system("cls");
   int i;
   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);
    fflush(0);
    printf("\nEnter percentage");
    scanf("%f",&s[i].per);
   }
   printf("Roll no \t Name \t Percentage");
   for(i=0;i<5;i++)
   {
      printf("\n");
      printf("%d\t %s \t %.2f ",s[i].rno,s[i].name,s[i].per);
   }
   
  return 0;
}

 

If you are Happy with DataFlair, do not forget to make us happy with your positive feedback on Google

courses

DataFlair Team

DataFlair Team provides high-impact content on programming, Java, Python, C++, DSA, AI, ML, data Science, Android, Flutter, MERN, Web Development, and technology. We make complex concepts easy to grasp, helping learners of all levels succeed in their tech careers.

Leave a Reply

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