calculator in C++,C++ basics,C++ Programming
Hi, My name is Bilal Ahmad and I am here now to tell you how you can now make a simple basic calculator in C++. And in this calculator, you can simply add the numbers. So let's start the Programme.
Calculator in C++:
#include<iostream>
using namespace std;
int main()
{
int add=0,user1=0,user2=0;
cout<<"please enter the 1st number=";
cin>>user1;
cout<<"please enter the 2nd number=";
cin>>user2;
//to add in the number
add=user1+user2;
cout<<"the addition of number ="<<add<<endl;
return 0;
}
Explanation of program
so now I will explain what actually happens in this program.
so, first of all, we should take input from the user.
so, then take the 2nd number from the user.
then we use the add variable so we can get the addition of a number and it will saif the addition of two numbers
then we simply show the output of addition and it will show the addition of numbers.
Example of this program.
Now we will see the Example here.
for example,
first of all, the user put 5 in the first input.
then the user put 10 in the 2nd input.
the program then takes the input and save the number in variable add.
and then finally it shows output 15.
So hope to see you in the next posts.
With best regards
Bilal Ahmad.
Calculator in C++:
#include<iostream>
using namespace std;
int main()
{
int add=0,user1=0,user2=0;
cout<<"please enter the 1st number=";
cin>>user1;
cout<<"please enter the 2nd number=";
cin>>user2;
//to add in the number
add=user1+user2;
cout<<"the addition of number ="<<add<<endl;
return 0;
}
Explanation of program
so now I will explain what actually happens in this program.
so, first of all, we should take input from the user.
so, then take the 2nd number from the user.
then we use the add variable so we can get the addition of a number and it will saif the addition of two numbers
then we simply show the output of addition and it will show the addition of numbers.
Example of this program.
Now we will see the Example here.
for example,
first of all, the user put 5 in the first input.
then the user put 10 in the 2nd input.
the program then takes the input and save the number in variable add.
and then finally it shows output 15.
So hope to see you in the next posts.
With best regards
Bilal Ahmad.

Really helpful
ReplyDeleteBro Please Use More meaningful variables and add a statement asking operators. It only does addition. Thank you.
ReplyDelete