C Exercises: Calculate the sum of the two integers
C Basic Declarations and Expressions: Exercise-9 with Solution
Write a C program that accepts two integers from the user and calculates the sum of the two integers.
Pictorial Presentation:

C Code:
#include <stdio.h>
int main()
{
int x, y, sum; // Declare variables for two integers and their sum
// Prompt user for input and store in 'x'
printf("\nInput the first integer: ");
scanf("%d", &x);
// Prompt user for input and store in 'y'
printf("\nInput the second integer: ");
scanf("%d", &y);
sum = x + y; // Calculate the sum of 'x' and 'y'
// Print the sum
printf("\nSum of the above two integers = %d\n", sum);
return 0; // Indicate successful execution
}
Sample Output:
Input the first integer: 25 Input the second integer: 38 Sum of the above two integers = 63
Flowchart:

C Programming Code Editor:
Previous: Write a C program to convert specified days into years, weeks and days.
Next: Write a C program that accepts two integers from the user and calculate the product of the two integers.
What is the difficulty level of this exercise?
Test your Programming skills with w3resource's quiz.
- Weekly Trends
- Python Interview Questions and Answers: Comprehensive Guide
- Scala Exercises, Practice, Solution
- Kotlin Exercises practice with solution
- MongoDB Exercises, Practice, Solution
- SQL Exercises, Practice, Solution - JOINS
- Java Basic Programming Exercises
- SQL Subqueries
- Adventureworks Database Exercises
- C# Sharp Basic Exercises
- SQL COUNT() with distinct
- JavaScript String Exercises
- JavaScript HTML Form Validation
- Java Collection Exercises
- SQL COUNT() function
- SQL Inner Join