C语言_基础知识

版权声明:转载请注明出处 https://blog.csdn.net/nanhuaibeian/article/details/86543712
  1. 实例
# include <stdio.h>
int main()
{
	int a,b,sum,max;
	printf("请输入a和b的值以逗号隔开:"); 
	//scanf是输入函数的名字
	scanf("%d,%d",&a,&b);
	sum = a+b;
	if(a>b)	max = a;
	else max = b;
	printf("a与b的和为: %d\n",sum); 
	printf("a与b的最大值为:%d",max);
	//代表单行注释 
	/*代表
	成块注释*/
	return 0;
}
  1. 分析
    使用函数库中的输入输出函数时,编译系统要求程序提供有关此函数的信息(例如对这些函数输入输出的声明和宏的定义、全局量的定义等)程序第一行‘# include <stdio.h>’作用就是提供这些信息。
    简单理解,程序中如果用到标准函数库中的输入输出函数,就应添加上
    ‘# include <stdio.h>’

猜你喜欢

转载自blog.csdn.net/nanhuaibeian/article/details/86543712