September 15th, 2012, 12:48 PM
Join Date: Sep 2012
Time spent in forums: 28 m 55 sec
Reputation Power: 0
Really simple program
I am trying to make a really simple program that calculates your grade based on percentages that certain things are worth. im pretty much brand new to c programming and just trying to goof around with my own ideas inbetween class projects. heres my code
float test; // based on tests being worth 30% of grade
float final; // based on tests being worth 20% of grade
float labs; // based on tests being worth 50% of grade
printf("Please enter your average test grade\n");
printf("Please enter your final test grade\n");
printf("please enter your average lab grade\n");
grade = (test * .30) + (final * .20) + (labs * .50);
printf("your grade for this class is: %0.2f", grade);
and i get this error when compiling
In function ‘main’:
c-projects/personal/grade_calc.c:19:1: warning: format ‘%f’ expects argument of type ‘float *’, but argument 2 has type ‘double’ [-Wformat]
so the error is with the %f thats supposed to be assigned to labs but im not really sure why thats an error.
any help would be greatly appreciated, i know its probably something silly that im just not seeing but have been looking at this for over an hour now and cant put my finger on it.
edit for error message because i was testing out %d instead of %f and posted the old message from test.