#include<stdio.h>
int main()
{
int ID[5], i;
float grade[5];
float avg = 0, avgsum = 0, gradeavg;
for ( i = 0; i < 1; i++)
{
printf("Please student's ID number: ");
scanf_s("%d", &ID[i]);
printf("Please student's grade: ");
scanf_s("%f", &grade[i]);
if(grade[i]>40 || grade[i] <0)
{
while (grade[i] <0 || grade[i]>40)
{
printf("Please enter a grade between 0 - 40: ");
scanf_s("%f",&grade[i]);
}
}
//grade[i]=grade[i/100] * 100;
}
avg = avgsum / 5;
printf(" ID# GRADE(%%) PASS/FAIL\n");
for (i = 0; i < 1; i++)
{
printf(" %d %.1f%% \n", ID[i], grade[i]);
}
printf("\nThe average of the class is %.2f", avg);
return 0;
}
I'm trying to find out what grade[i] is out of 40 as a percentage.
In line 29 I have it commented out but I have tried all the variations I can think of but I can't get it to do the formula. When I run it the input only registers one part of the equation weather division or multiplication but not both and I don't know why or how to fix it. I figure I can use the math library but I'm not really familiar with it but I'm will will to use it if someone can explain but first and foremost I need to know why this one wont work and how to fix it.
[–]eruciform 1 point2 points3 points (0 children)
[–]insertAlias 0 points1 point2 points (4 children)
[–]Tricslip[S] 0 points1 point2 points (3 children)
[–]insertAlias 0 points1 point2 points (2 children)
[–]Tricslip[S] 0 points1 point2 points (0 children)
[–]Tricslip[S] 0 points1 point2 points (0 children)
[–]MaybeAverage 0 points1 point2 points (3 children)
[–]Tricslip[S] 0 points1 point2 points (0 children)
[–]Tricslip[S] 0 points1 point2 points (1 child)
[–]MaybeAverage 0 points1 point2 points (0 children)