C program to add two integer number
#include
int main()
{
int number1, number2, sum;
printf("Enter two integers: "); // Value from user
scanf("%d %d", &number1, &number2); // Storing value
// calculating sum
sum = number1 + number2;
printf("%d + %d = %d", number1, number2, sum); // Final result
return 0;
}
Output
Enter two integers: 12
11
12 + 11 = 23
How program works ?
- In this program, the user asked to enter two integer values. These integer values are stored in number1 and number2.
- Then, these two integer number are adding in ' + ' operator, and result is stored in the sum variable.
Sum = number1 + number2;
- Finally, printf() function is used to display the sum of two integer number.
printf("%d + %d = %d", number1, number2, sum); // Final result
0 comments:
Post a Comment