Skip to content
Home » Blog » C Program to Add Two Integers

C Program to Add Two Integers

Add Two Integers

In this Program, you’ll learn how to Add Two Integers.

Add Two Integers; In this program, the user is asked to enter two integers. Then, the sum of those two integers is stored in a variable and displayed on the screen.

In C language we have data types for different types of data, for integers, it is int, for characters it is char, for floating point data it’s float and so on. For large integers, you can use long or long long data type.

To store integers which are larger than (2^18-1) which is the range of long long data type you may use strings. In the below program we store an integer in a string and then added it.

To understand this example of C Print Integer, you should have the knowledge of following C programming topics:

  1. Constants
  2. Variables
  3. Data Types
  4. Input-Output
  5. Arithmetic Operators

Program to Add Two Integers

#include <stdio.h>
int main()
	int firstNumber, secondNumber, sumOfTwoNumbers;
	printf(“Enter two integers: “);

	// Two integers entered by user is stored using scanf() function
	scanf(“%d %d”, &firstNumber, &secondNumber);

	// sum of two numbers in stored in variable sumOfTwoNumbers
	sumOfTwoNumbers = firstNumber + secondNumber;

	// Displays sum
	printf(“%d + %d = %d”, firstNumber, secondNumber, sumOfTwoNumbers);

	return 0;


Enter two integers: 12
12 + 11 = 23

C Program to Add Two Integers

In this program of Add Two Integers, the user is asked to enter two integers. Two integers entered by the user is stored in variables firstNumber and secondNumber respectively. This is done using scanf()function.

Then, variables firstNumber and secondNumber are added using + operator and the result is stored in sumOfTwoNumbers.

Finally, the sumofTwoNumbers is displayed on the screen using printf() function.

Ask your questions about how to Add Two Integers in C and clarify your/others doubts by commenting. Documentation.

Related Program

  1. C Program to compute Quotient and Remainder.
  2. C Program to Find ASCII value of a Character.
  3. C Program to Swap two Numbers.
  4. C Program to Find the size of int, float, double and char.
  5. C Program to Multiply two floating point Numbers.
  6. C Program to Implement stack.
  7. C Program to Implement circular linked list List.
  8. C Program to calculate compound interest.