The conversion specification %.00f requests 0 digits after the decimal point, so that's what you get. If you want 2 digits after the decimal point, then use %.2f (or maybe %6.2f).
To fix the point that Matteo Pacini made in his comment, and deal with miscellaneous other issues too, you could use a variant of your code similar to this:
#include <stdio.h>
int main(void)
{
int grades[20];
char names[20][20];
int a, b, f, high, g, loc;
float avg, tot = 0;
for (a = 0; a < 20; a++)
{
printf("Input Name %d: ", a+1);
if (scanf("%19s", names[a]) != 1)
return 1;
}
for (b = 0; b < 20; b++)
{
int e;
printf("Input Marks %d: ", b+1);
if (scanf("%d", &e) != 1)
return 1;
if (e >= 0 && e <= 100)
grades[b] = e;
else
{
printf("OUT OF RANGE.PLEASE INPUT A VALID NUMBER.\n");
b--;
}
}
putchar('\n');
for (a = 0; a < 20; a++)
printf("%-20s %3d\n", names[a], grades[a]);
for (f = 0; f < 20; f++)
tot = tot + grades[f];
printf("Total is %6.2f\n", tot);
avg = tot / 20.00;
printf("Average is %6.2f\n", avg);
high = grades[0];
loc = 0;
for (g = 0; g < 20; g++)
{
if (high < grades[g])
{
high = grades[g];
loc = g;
}
}
printf("The average is %6.2f\n", avg);
printf("The highest grade is %d\n", high);
printf("The name of the person who has the highest grade is: %s\n", names[loc]);
return 0;
}
Given sample input data like this (file ga.marks), where the data was generated by two programs:
Student-01
Student-02
Student-03
Student-04
Student-05
Student-06
Student-07
Student-08
Student-09
Student-10
Student-11
Student-12
Student-13
Student-14
Student-15
Student-16
Student-17
Student-18
Student-19
Student-20
49
27
47
46
33
84
63
51
61
91
82
60
39
57
65
60
19
88
47
61
This is the output from running the program (named ga) as: ga < ga.marks (because I am not going to sit around typing 20 names and 20 numbers as input to a program):
Input Name 1: Input Name 2: Input Name 3: Input Name 4: Input Name 5: Input Name 6: Input Name 7: Input Name 8: Input Name 9: Input Name 10: Input Name 11: Input Name 12: Input Name 13: Input Name 14: Input Name 15: Input Name 16: Input Name 17: Input Name 18: Input Name 19: Input Name 20: Input Marks 1: Input Marks 2: Input Marks 3: Input Marks 4: Input Marks 5: Input Marks 6: Input Marks 7: Input Marks 8: Input Marks 9: Input Marks 10: Input Marks 11: Input Marks 12: Input Marks 13: Input Marks 14: Input Marks 15: Input Marks 16: Input Marks 17: Input Marks 18: Input Marks 19: Input Marks 20:
Student-01 49
Student-02 27
Student-03 47
Student-04 46
Student-05 33
Student-06 84
Student-07 63
Student-08 51
Student-09 61
Student-10 91
Student-11 82
Student-12 60
Student-13 39
Student-14 57
Student-15 65
Student-16 60
Student-17 19
Student-18 88
Student-19 47
Student-20 61
Total is 1130.00
Average is 56.50
The average is 56.50
The highest grade is 91
The name of the person who has the highest grade is: Student-10
Note that the prompts are counter-productive for input from file. The code echoes its input at the end of the input. It does the calculations etc. I didn't bother to tune the data to produce a mean score of 48.95.
scanf("%s",&names[a])is completely wrong. names is an array of chars, not an array of strings!