C++ Exercises: Print the sum of two numbers
Sum of Two Numbers
Write a program in C++ to print the sum of two numbers.
Visual Presentation:

Sample Solution:
C++ Code :
#include <iostream> // Including the input-output stream header file
using namespace std; // Using the standard namespace
int main() // Start of the main function
{
cout << "\n\n Print the sum of two numbers :\n"; // Outputting a message for displaying the sum of two numbers
cout << "-----------------------------------\n"; // Outputting a separator line
cout << " The sum of 29 and 30 is : "<< 29+30 <<"\n\n" ; // Calculating and outputting the sum of 29 and 30
} // End of the main function
Sample Output:
Print the sum of two numbers : ----------------------------------- The sum of 29 and 30 is : 59
Flowchart:

For more Practice: Solve these Related Problems:
- Write a C++ program to compute the sum of two numbers read from the user, but perform the addition without using the '+' operator.
- Write a C++ program that calculates the sum of two numbers and prints the result in a formatted box using special characters.
- Write a C++ program that reads two numbers as strings, converts them to integers, and then prints their sum.
- Write a C++ program to add two numbers where one of the numbers is generated randomly and the other is input by the user.
C++ Code Editor:
Previous: Write a program in C++ to print a welcome text in a separate line.
Next: Write a program in C++ to find Size of fundamental data types.
What is the difficulty level of this exercise?