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:
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?
- Weekly Trends and Language Statistics
- Weekly Trends and Language Statistics