You are on page 1of 1

#include <stdio.

h>
#include <stdlib.h>

struct studentInfo{
char name[20];
char surname[20];
float avg;
};

int main(void){

int n,i;
printf("Enter the number of students: ");
scanf("%d",&n);

struct studentInfo s[n];

for(i=0;i<n;i++){
printf("Enter the name of student %d: ",i+1);
scanf("%s",&s[i].name[20]);
printf("Enter the surname of student %d: ",i+1);
scanf("%s",&s[i].surname[20]);
printf("Enter the average of student %d: ",i+1);
scanf("%f",&s[i].avg);
printf("****\n");
}
float max=0;
int highindex;

for(i=0;i<n;i++){
if(s[i].avg>max)
{
max = s[i].avg;
highindex = i;
}
}

printf("Student with the highest net average is: %s",s[highindex].name);


printf(" %s",s[highindex].surname);
printf(" with an average of %.2f",s[highindex].avg);

return 0;

You might also like