Structure of the Record of some Students
Structure of the Record of some Students Source Code: #include<stdio.h> #include<conio.h> #include<string.h> struct student { char name[30]; int roll; int marks; }; void main() { int i,j,n; struct student s[30],a; clrscr(); printf("Enter number of students:"); scanf("%d",&n); for(i=0;i<=n-1;i++) { printf("\nEnter name of the student:"); scanf("%s",s[i].name); printf("\nEnter roll no. and marks of the student:"); scanf("%d %d",&s[i].roll,&s[i].marks); } printf("\n NAME ROLL MARKS"); printf("\n***************************************"); for(i=0;i<=n-1;i++) { printf("\nstu%d %s %d %d",i+1,s[i].name,s[i].roll,s[i].marks); } a=s[0]; for(i=0;i<=n-1;i++) { if(s[i].marks>a.marks) a=s[i]; } printf("\n\n\nRecord of the student who got highest marks:"); printf("\n\nNAME %s",a.name); printf("\nROLL %d",a.roll); printf("\nMARKS %d",a.marks); getch(); } OUTPUT : Enter number of students:5 Enter name of the student:Ram Enter roll no. and marks of the student:48 65 Enter name of the student:Shyam Enter roll no. and marks of the student:15 75 Enter name of the student:Rahul Enter roll no. and marks of the student:117 78 Enter name of the student:Rohit Enter roll no. and marks of the student:180 83 Enter name of the student:Nasir Enter roll no. and marks of the student:52 72 NAME ROLL MARKS *************************************** stu1 Ram 48 65 stu2 Shyam 15 75 stu3 Rahul 117 78 stu4 Rohit 180 83 stu5 Nasir 52 72 Record of the student who got highest marks: NAME Rohit ROLL 180 MARKS 83
Tags:
C Program
0 comments