0% found this document useful (0 votes)
4 views

Simple CPP Program

This document provides a simple C++ program that takes two numbers as input, adds them, and displays the result. It includes the code, steps to run the program, and a sample output. The program demonstrates basic input/output operations and arithmetic calculations in C++.

Uploaded by

raj.kp2211
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views

Simple CPP Program

This document provides a simple C++ program that takes two numbers as input, adds them, and displays the result. It includes the code, steps to run the program, and a sample output. The program demonstrates basic input/output operations and arithmetic calculations in C++.

Uploaded by

raj.kp2211
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Simple C++ Program for Beginners

This C++ program takes two numbers as input from the user, adds them, and displays the result.

It demonstrates basic input/output operations and arithmetic calculations in C++.

#include <iostream>
using namespace std;

int main() {
int num1, num2, sum;

cout << "Enter the first number: ";


cin >> num1;

cout << "Enter the second number: ";


cin >> num2;

sum = num1 + num2;

cout << "The sum of " << num1 << " and " << num2 << " is " << sum << "." << endl;

return 0;
}

Steps to Run the Program:

1. Copy the code into a C++ IDE or text editor (e.g., Code::Blocks, VS Code).

2. Compile using a compiler like g++:

g++ program.cpp -o program

3. Run the compiled file:

./program

Sample Output:
Enter the first number: 5
Enter the second number: 10
The sum of 5 and 10 is 15.

You might also like