用c语言写一个程序说明其功能
#include <stdio.h>
int main() { int num1, num2, sum;
printf("Enter the first number: ");
scanf("%d", &num1);
printf("Enter the second number: ");
scanf("%d", &num2);
sum = num1 + num2;
printf("The sum of %d and %d is %d\n", num1, num2, sum);
return 0;
}
这个程序的功能是接受用户输入的两个整数,计算它们的和,并将结果打印出来。程序首先提示用户输入第一个数,然后使用scanf函数将用户输入的值存储到num1变量中。接下来,程序提示用户输入第二个数,将其存储到num2变量中。然后,程序将num1和num2相加,将结果存储在sum变量中。最后,程序使用printf函数将结果打印出来。
原文地址: https://www.cveoy.top/t/topic/igiZ 著作权归作者所有。请勿转载和采集!