Write a C program to enter 4 module marks of 3 students and display their total marks. Display the student with the highest total mark.
Answers
Answer:
#include<stdio.h>
void main()
{
int marks;
printf("Enter your marks ");
scanf("%d",&marks);
if(marks<0 || marks>100)
{
printf("Wrong Entry");
}
else if(marks<50)
{
printf("Grade F");
}
else if(marks>=50 && marks<60)
{
printf("Grade D");
}
else if(marks>=60 && marks<70)
{
printf("Grade C");
}
else if(marks>=70 && marks<80)
{
printf("Grade B");
}
else if(marks>=80 && marks<90)
{
printf("Grade A");
}
else
{
printf("Grade A+");
}
}
Answer:
#include<stdio.h>
/* Declaration of structure */
struct student
{
char name[30];
int roll;
float marks;
};
int main()
{
/* Declaration of array of structure */
struct student s[20], lg;
int i,n;
printf("Enter n:\n");
scanf("%d",&n);
for(i=0;i< n;i++)
{
printf("Enter name, roll and marks of student:\n");
scanf("%s%d%f",s[i].name, &s[i].roll, &s[i].marks);
}
lg = s[0];
for(i=0;ilg.marks)
{
lg = s[i];
}
}
printf("Student obtaing highest marks is:\n");
printf("Name: %s\n", lg.name);
printf("Roll: %d\n", lg.roll);
printf("Marks: %0.2f\n", lg.marks);
return 0;
}
Explanation: