Knowing that the scores of a student in math, English and computer courses are 87, 72, and 93 respectively, find the average score of the student's 3 courses (the results are output as integers).
Input format:
No input for this question
Output format:
Output the results in the following format:
math = 87, eng = 72, comp = 93, average = 计算所得的平均成绩
Code:
# include <stdio.h>
# include <stdlib.h>
int main(){
int math = 87,eng = 72,comp = 93,average;
average = (math + eng + comp) / 3;
printf("math = %d, eng = %d, comp = %d, average = %d",math,eng,comp,average);
return 0;
}
Submit screenshot:
Problem-solving ideas:
Title relatively simple, nothing more than the creation and assignment variable, average note final output is an integer, so defined average
when the variables can be defined as the direct int
type, may of course be provided double
, or float
, when the symbol with the final output format %0lf
, or%0f