Yahoo Answers is shutting down on May 4th, 2021 (Eastern Time) and beginning April 20th, 2021 (Eastern Time) the Yahoo Answers website will be in read-only mode. There will be no changes to other Yahoo properties or services, or your Yahoo account. You can find more information about the Yahoo Answers shutdown and how to download your data on this help page.
Trending News
How to calculate the average mark of the 3 subjects using C programming?
Help me with this c programing please, bad at it
/*Name; Class:
This program calculates the average of 3 subjects using floating point division.*/
#include <stdio.h>
void main(void)
{
average = sum / 3.0;
int cp, ee, em, sum;
cp = 90;
ee = 60;
em = 80;
float average;
printf('The average = %f\n", average');
sum = cp + ee + em;
}// end main
1 Answer
- ?Lv 77 years agoFavorite Answer
There's no such thing as void main first off, even if your compiler doesn't complain.
you simply need to do things in the right order logically.
Also in the older C standard all variables need to be declared at the top. Your printf line needed to change too.
#include <stdio.h>
int main(void)
{
int cp, ee, em, sum;
float average;
cp = 90;
ee = 60;
em = 80;
sum = cp + ee + em;
average = sum / 3.0;
printf("The average = %f\n", average);
return 0;
}// end main