Program to perform addition of two numbers in c

Here is a C Program to do perform the addition of two numbers in c programming using basic arithmetic operation of adding two numbers and then print their sum on the user’s screen. For example, if a user will input two numbers as; ‘1’, ‘2’ then ‘3’ (1 + 2) should be printed on the user’s screen.

Program to Add an Integer

include <stdio.h>
int main() {
int firstNum, secondNum, sumOfTwoNum;
printf("Enter two integers : ");
// Two integers will be entered by user using scanf() function
scanf("%d %d", &firstNum, &secondNum);
// sum of two numbers is stored in a variable sumOfTwoNumbers
sumOfTwoNum = firstNum + secondNum;
// Displays sum uing Printf() function
printf("%d + %d = %d", firstNum, secondNum, sumOfTwoNum);
return 0;


Enter two integers: 1
1 + 2 = 3


In this program, the user is asked to enter two integers using scanf() function. which are stored in variables firstNum and secondNum respectively.

after this, variables firstNum and secondNum are added using + ( Binary operator ) and the result is stored in a variable named sumOfTwoNum.

Let’s consider an example below

perform sum of two numbers in c

Now Finally, the sumofTwoNum is displayed on the Users screen using printf() function.

Notify of
Inline Feedbacks
View all comments