What's the error in this program..i get student data and print maximum total marks | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

What's the error in this program..i get student data and print maximum total marks

#include<stdio.h> #include<conio.h> struct student { char name[20]; int rollno; int mark[4]; int sum; }s[100],a; void main() { int i,j,k,n,s[i].sum=0; printf("enter no of students"); scanf("%d",&n); for(i=0;i<n;i++) { printf("enter name"); gets(s[i].name); printf("enter roll no"); scanf("%d",s[i].rollno); printf("enter marks"); for(j=0;j<4;j++) { scanf("%d",s[i].mark[j]); } printf("..................\n"); } for(i=0;i<n;i++) { for(j=0;j<4;j++) {s[i].sum=s[i].sum+s[i].mark[j]; } } for(i=0;i<n;i++) { for(j=i+1;j<n;i++) { if(s[i].sum<s[j].sum) { a=s[i]; s[i]=s[j]; s[j]=a; } } } printf("max mark is %d",s[0].sum); getch(); }

12th Feb 2020, 2:55 AM
Ragul P
Ragul P - avatar
1 Answer
+ 3
If you need help, please post the code on code-bite. Then share it here.. Follow this post 👇👇 https://www.sololearn.com/post/75089/?ref=app thank you
12th Feb 2020, 3:57 AM
Scooby
Scooby - avatar