C program to print the total mark and average mark of five subjects.

 

C program
C PROGRAM

C program to print the total mark and average mark of five subjects

#include<stdio.h>
int main()
{
struct student
{
int sub1,sub2,sub3,sub4,sub5,tot;
float avg;
}s;
int n,i,a[n];
printf("Enter no. of students: ");
scanf("%d",&n);
for(i=0;i<n;i++)
{
printf("\nEnter the marks for student %d: \n",i+1);
scanf("%d%d%d%d%d",&s.sub1,&s.sub2,&s.sub3,&s.sub4,&s.sub5);
s.tot = s.sub1 + s.sub2 + s.sub3 + s.sub4 + s.sub5;
s.avg =(s.sub1 + s.sub2 + s.sub3 + s.sub4 + s.sub5)/5.0;printf("\nThe total mark of student %d : %d",i+1,s.tot);
printf("\nThe average mark of student %d : %.2f\n",i+1,s.avg); }

return 0;

OUTPUT:

Enter no. of students: 2
Enter the marks for student 1: 
90
89
94
96
97
The total mark of student 1 : 466
The average mark of student 1 : 93.20
Enter the marks for student 2: 
89
90
99
96
95
The total mark of student 2 : 469
The average mark of student 2 : 93.80
Process finished. 

Comments

Popular posts from this blog

Write a program to calculate a students result based on two examinations, 1 sports event, and 3 activities conducted. The weightage of activities= 30%, sports= 20% , and examinations= 50%.

Determine the intensity of shear of an oil having viscosity= 1 poise. The oil is used for lubricating the clearance between a shaft of diameter 10 cm and its journal bearing. The clearance is 1.5mm and the shaft rotates at 150 r.p.m.