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:
- C Data Types
- C Variables, Constants and Literals
- C Input Output (I/O)
- C Programming Operators
Program to Add Two Integers
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:
- SEO Practices Everyone Should Follow SEO Rules
- Complete Top SEO Checklist
- Yoast Seo Premium 15.2 Nulled – WordPress SEO Plugin
- Top 50+ SEO Interview Questions
- What is a Backlink? How to Get More Backlinks
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 !