Write an application that creates 2 variable of type integer

Write an application that creates 2 variable of type integer. Prompt the user to enter two integer values, and assigns each value to one of the variables. Then calculate and print the sum, product, difference and quotient.

Solution

C++ Code for the problem:

#include <bits/stdc++.h>
using namespace std;

int main()
{
   int n1;
   int   n2;
cout << \"Enter first number\"<<endl;   
cin >> n1;
cout << \"Enter Second number\"<<endl;   
cin >> n2;
cout <<\"Sum Of the Numbers is \" << n1 + n2 << endl;
cout <<\"Product Of the Numbers is \"<< n1 * n2<< endl;
cout <<\"Difference Of the Numbers is \"<< abs(n1 - n2) << endl;
cout <<\"Quotient of number1/number2 is \"<< n1/n2 << endl;
return 0;
}

Sample output:

Enter first number
4
Enter Second number
2
Sum Of the Numbers is 6
Product Of the Numbers is 8
Difference Of the Numbers is 2
Quotient of number1/number2 is 2

Write an application that creates 2 variable of type integer. Prompt the user to enter two integer values, and assigns each value to one of the variables. Then

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site