C语言程序设计教案资料.ppt

/* example1.1 The first C Program*/ #include stdio.h main() { printf(“Hello.”); } 注释 编译预处理 函数 语句 输出: 1.2 C程序初识 1.2.1 简单C程序案例 例:第一个程序,输出一条信息 Hello. Hello. 例:求两个整数a、b累加和。 /* example calculate the sum of a and b */ #include stdio.h /* This is the main program */ main() { int a,b,sum; a=10; b=24; sum=add(a,b); printf(”sum= %d\n,sum); } /* This function calculates the sum of x and y */ int add(int x,int y) { int z; z=x+y; return(z); } 运行结果: 函数 预处理命令 注释 sum=34 1.2.2 C程序基本构成 1.函数与主函数 程序由一个或多个函数组成 有且仅有一个主函数main() 程序执行从main开始,在main中结束,其它函数通过嵌套调用得以执行。 C函数由

您可能关注的文档

文档评论(0)

1亿VIP精品文档

相关文档