使用 scanf() 来接收输入, printf() 与 %d 格式化输出整数。
运行实例实例
#include <stdio.h>
int main()
{
int firstNumber, secondNumber, sumOfTwoNumbers;
printf("输入两个数: ");
scanf("%d %d", &firstNumber, &secondNumber);
sumOfTwoNumbers = firstNumber + secondNumber;
printf("%d + %d = %d", firstNumber, secondNumber, sumOfTwoNumbers);
return 0;
}
运行结果:
输入两个数(以空格分割): 3 4
3+4=7
标签:int,相加,printf,C语言,sumOfTwoNumbers,firstNumber,实例,secondNumber From: https://blog.51cto.com/u_16216241/8465550