Share
Explore BrainMass

# C Coding and Average GPA

1. My C code cant compile and i cant see the problem can u fix it?

2. write a c code or Modify the code to ask user to input 5 gpas. then the program calculates the average of the gpa and prints it to screen. i.e(The average of all Gpas you entered is 3.87). this code should also check gor negative inputes ie( if user inputs -2.6 or a gpa hight or lower than 1 to 4.0, it print invalisd gpa to the screen.

--------------------------------------------------------------------------------------------
#include <stdio.h>

main ()

/* This C code outputs the equivalent GPA letter grade of a student */
{
float x;

printf("Please enter a GPA value: n");
scanf("%f", &x);

/* An if else statement that sonditions the out of grades*/

if (x < 1.0)
{
Printf("A gpa of %.0f is a grade F: n", x);
}
else if (x >= 1.0 || x < 1.7)
{
Printf("A gpa of %.0f is a grade D: n", x);
}
else if (x >= 1.7 || x < 2.7)
{
printf("A gpa of %.0f is a grade C: n", x);
}
else if (x >= 2.7 || x < 3.5)
{
printf("A gpa of %.0f is a grade B: n", x);
}
else if (x >= 3.5)
{
printf("A gpa of %.0f is a grade A: n", x);
}
return (1);
}

\$2.19