A Program to Add Two Integer Numbers

In this example, we are giving a program to add two integer numbers which are given by the user.


Program to add two integer numbers:

  1. #include <stdio.h>
  2. int main()
  3. {
  4. int first_number, second_number, sum;
  5. printf("Enter two integers: ");
  6. // Two integers entered by user stored
  7. scanf("%d %d", &first_number, &second_number);
  8. // Sum of the two numbers stored in the variable sum
  9. sum = first_number + second_number;
  10. // Displaying the value of sum
  11. printf("%d + %d = %d", first_number, second_number, sum);
  12. return 0;
  13. }

Output:

Enter two integers: 7
17
7 + 17 = 24