How we can add,subtract,multiply in c++ code


It is very easy to add two numbers, subtract, multiply and divide two numbers in c++ .
First we make three objects and than input two objects and give the value of third object.

Code:

(i)How we can Plus in c++ Code:

#include <iostream>
using namespace std;
int main() {
int num1,num2,ans;
cout<<"Enter First number : ";
cin>>num1;
cout<<"Enter Second number : ";
cin>>num2;
ans= num1+num2;
cout<<"ANS : "<<ans;
}

(ii)How we can Subtract in c++ Code:

#include <iostream>
using namespace std;
int main() {
int num1,num2,ans;
cout<<"Enter First number : ";
cin>>num1;
cout<<"Enter Second number : ";
cin>>num2;
ans= num1-num2;
cout<<"ANS : "<<ans;
}

(iii)How we can Multiply in c++ Code:

#include <iostream>
using namespace std;
int main() {
int num1,num2,ans;
cout<<"Enter First number : ";
cin>>num1;
cout<<"Enter Second number : ";
cin>>num2;
ans= num1*num2;
cout<<"ANS : "<<ans;
}

(iv)How we can Divide in c++ Code:

#include <iostream>
using namespace std;
int main() {
int num1,num2,ans;
cout<<"Enter First number : ";
cin>>num1;
cout<<"Enter Second number : ";
cin>>num2;
ans= num1/num2;
cout<<"ANS : "<<ans;
}

Click Here For Whatching Video of Given Code

avatar
AUTHOR: Muhammad Abbas
I am Software Engineer.

0 Comments