C语言基础:简单的数学运算
#include <stdio.h> int main () { int seconds_in_an_hour; float average; seconds_in_an_hour = 60 * 60; average = (5 + 10 + 15 + 20) / 4; printf("The number of seconds in an hour %d\n", seconds_in_an_hour); printf("The average of 5, 10, 15, and 20 is %f\n", average); printf("The number of seconds in 48 minutes is %d\n", seconds_in_an_hour - 12 * 60); return 1; }
gcc编译运行输出结果
The number of seconds in an hour 3600 The average of 5, 10, 15, and 20 is 12.000000 The number of seconds in 48 minutes is 2880