This is C program that asks user to find out the highest marks and average of students. Here declaring required variables for storing the value. User declares an array type variable in this user puts the value static up to 10 element. Using clear screen method user also uses the loop statement for vary the condition for average and marks into it. And a control statement also use for getting the condition true. if (mark[i] > highest) then the highest marks will be in mark[i].
Then finding out the average of students on the base of marks. In the end to display result on the screen.
Problem statement:
This is C program that asks user to find out the highest marks and the average.
- Declaring the variables.
- Using conditions.
- Using method for average calculating.
- Display result on the screen.
This is C program to find out highest marks and average. Output of this program shown below.
#include <stdio.h>
int main ()
{
float mark[10] = {45.6, 78.4, 65.9, 58.3, 82.1, 44.5, 61.8, 53.6, 49.2, 37.7};
int i;
float sum = 0, average, highest = 0;
clrscr();
for (i = 0; i < 10; i++)
{
sum += mark[i];
if (mark[i] > highest)
highest = mark[i];
}
average = sum / 10.0;
printf("The Average Mark is %5.2f \n", average);
printf("The Highest Mark is %5.2f \n", highest);
getch();
return 0;
}
Output :