一个简单的C程序 C sum.c /Example:calculate the e sum of a and b #include <stdio.h> 预处理:载入头文件 注解语句 main() 主函数 int a,b,sumj a=10; 打印语句 b=24; sum a+b; printf("sum=%d\n",sum); C源程序结构: ● 一个C源程序由一个或多个源文件组成 return 0; ● 每个源文件可由一个或多个函数组成 ● 一个源程序有且只能有一个main函数 ●程序执行从main开始,在main中结束 源程序中可以有预处理命令,通常应放 在源文件或源程序的最前面 http://math.ecnu.edu.cn/~jypan http://math.ecnu.edu.cn/~jypan 一个简单的 C 程序 7 /* Example: calculate the sum of a and b */ #include <stdio.h> main() { int a, b, sum; a=10; b=24; sum = a+b; printf("sum=%d\n", sum); return 0; } 主函数 打印语句 预处理:载入头文件 注解语句 C 源程序结构: 一个 C 源程序由一个或多个源文件组成 每个源文件可由一个或多个函数组成 一个源程序有且只能有一个 main 函数 程序执行从 main 开始,在 main 中结束 源程序中可以有预处理命令,通常应放 在源文件或源程序的最前面 C_sum.c