Example 1-2-1 Find the sum of two integers (1)
The topic description
sets up 3 variables a, b, sum, of which a, b is used to store two integers, and sum is used to store the sum of two numbers a and b, through assignment (that is, the assignment operator "=") Initialize a to 123 and b to 456, and assign the result of adding the two variables to sum.
Input
none, the variable is given initial value in the program by way of assignment.
Output
sum=Result
sample input Copy
no
sample output Copy
sum=579
#include <stdio.h>
int main()
{
int a=123,b=456,sum;
sum=a+b;
printf("sum=%d",sum);
return 0;
}