请解析这个C语言程序

来源:百度知道 编辑:UC知道 时间:2024/06/07 18:17:24
#include<stdio.h>
int sum(int a,int b)
{
a=a+b;
b=a+b;
return a;
}
void main()
{
int a=1,b=3,c;
c=sum(a,b);
printf("Sum of %d,%d is %d\n",a,b,c);
}

请逐句解释.

#include<stdio.h> //包含标准头文件
int sum(int a,int b) //定义函数
{
a=a+b; //执行后结果a等于4
b=a+b; //执行后b等于7
return a; //返回a的值,等于4
}
void main() //主函数
{
int a=1,b=3,c; //初始化a,b,c
c=sum(a,b); //求和
printf("Sum of %d,%d is %d\n",a,b,c); //打印结果
}