Question
Create a new project. Type in the following program. Add a comment at the top to include your name and the date. 2. Compile and
//this program demonstrates the use of various operators
#include
using namespace std;
int main()
{
int num1;
int num2;
int sum;
int diff;
int prod;
float quot;
cout << "Enter two integer values" << endl;
cin >> num1 >> num2;
sum = num1 + num2;
cout << num1 << " + " << num2 << " is " << sum << endl;
diff = num1 - num2;
cout << num1 << " - " << num2 << " is " << diff << endl;
prod = num1 * num2;
cout << num1 << " * " << num2 << " is " << prod << endl;
quot = (float) num1 / num2;
cout << num1 << " / " << num2 << " is " << quot << endl;
return 0;
}
if (num2 == 0)
{
cout << cannot divide by zero! << endl;
}
else
{
}
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started