Program to calculate the total of marks and percentage.


C File =>



/* Write a C program to create a structure named student that accepts student roll no, name and marks of 3 subjects. Calculate the total of marks and percentage. Create an array of structures to enter information for n students and display the details. */


#include<stdio.h>
typedef struct Student
{
    int rno;
    char name[30];
    int m1,m2,m3;
};
int main()
{
    struct Student s[50];
    int n,i,total[50];
    float perc[50];
    printf("\n How many students? ");
    scanf("%d",&n);
    for(i=0;i<n;i++)
    {
       printf("\n\n Enter Roll no %d : ",i+1);
       scanf("%d",&s[i].rno);
       printf("\n Enter name%d : ",i+1);
       scanf("%s",s[i].name);
       printf("\n Enter makrs1, marks2 and marks3 : ");
       scanf("%d%d%d",&s[i].m1,&s[i].m2,&s[i].m3);
       //calculating total and percentage
       total[i]=s[i].m1+s[i].m2+s[i].m3;
       perc[i]=(total[i])/3;
     }
     printf("\n\n Details are : ");
     for(i=0;i<n;i++)
     {
        printf("\n\n Roll number : %d",s[i].rno);
        printf("\n Name : %s",s[i].name);
        printf("\n Marks1 : %d \n Marks2 : %d \n Marks3 : %d",s[i].m1,s[i].m2,s[i].m3);
        printf("\nTotal : %d",total[i]);
        printf("\n Percentage : %f",perc[i]);
      }
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”.