C Program to Add two numbers

C Program to Add two numbers

Program to add two integer numbers

To read the input numbers we are using scanf() function and then we are using printf() function to display the sum of these numbers. The %d used in scanf() and printf() functions is the format specifier which is used for int data types in C programming.

 

#include <stdio.h>
int main()
{
   int num1, num2, sum;
   printf("Enter first number: ");
   scanf("%d", &num1);
   printf("Enter second number: ");
   scanf("%d", &num2);

   sum = num1 + num2;
   printf("Sum of the entered numbers: %d", sum);
   return 0;
}

Output:

Enter first number: 20

Enter second number: 25

Sum of the entered numbers: 45

 

 

One thought on “C Program to Add two numbers

Comments are closed.