HomePOSTC Program to Add Two Integers Elements (updated)

C Program to Add Two Integers Elements (updated)

the user is asked to enter two integers. Then, the sum of these two integers is calculated and displayed on the screen. To understand this example, you should have the knowledge of the following C programming topics:

<img width=
  • C Data Types
  • C Variables, Constants and Literals
  • C Input Output (I/O)
  • C Programming Operators

Program to Add Two Integers

OUTPUT



Enter two integers: 13
11
13 + 11 = 24


In this program, the user is asked to enter two integers. These two integers are stored in variables number1 and number2 respectively.

printf("Enter two integers: ");
scanf("%d %d", &number1, &number2);


Then, these two numbers are added using the + operator, and the result is stored in the sum variable.

  • sum = number1 + number2;
  • Adding two integers in C programming
  • Add Two Numbers
  • Finally, the printf() function is used to display the sum of numbers.

printf("%d + %d = %d", number1, number2, sum);

Types of Sorting Algorithms:

Additional Reading

READ MORE

If you found this post useful, don’t forget to share this with your friends, and if you have any query feel free to comment it in the comment section.

Thank you 😊 Keep Learning !

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisment -

Most Popular

- Advertisment -