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.
|
No comments:
Post a Comment