This is a simple and easy c++ program to subtract two numbers entered by the user while executing this program. I assume you have basic knowledge of c++ programming language.
In the below program, we have used three variables x, y, and subtract. x and y to hold the value of entered by the user and then subtract the from variable1 to variable2 using subtract operator (-) and store into subtract variable.
Copy the below program and execute it with the help of CPP compiler.
using namespace std;
int x, y, subtract;
cout << "Enter two integers for subtract: ";
cin >> x >> y;
// the subtracted value of two numbers stored in the third variable
subtract = x - y;
// Prints subtracted value
cout << x << " - " << y << " = " << subtract;
Enter two integers for addition: 15
15 – 10 = 5
If you like FreeWebMentor and you would like to contribute, you can write an article and mail your article to [email protected] Your article will appear on the FreeWebMentor main page and help other developers.
Article Tags: c program, c programs, c++ programs for substraction, C++ Tutorial, how to subtract two numbers, how to subtract two numbers using c++, subtract two numbers, subtracting two negative numbers