Consider the following program:
#include
#include
#include
using namespace std;
int main()
{
int num1;
int num2;
cout << fixed << showpoint <<
setprecision(2);
cout << "Enter two integers: ";
cin >> num1 >> num2; cout << endl;
if (num1 != 0 && num2 != 0)
cout << sqrt(abs(num1 + num2) + 0.5) << endl;
else if (num1 != 0)
cout << floor(num1 + 0.5) << endl;
else if (num2 != 0)
cout << ceil(num2 + 0.5) << endl;
else
cout << 0 << endl;
return 0;
}
a. What is the output if the input is -23 8?
b. What is the output if the input is 12 32?
c. What is the output if the input is 15 0?
d. What is the output if the input is 0 -36?
e. What is the output if the input is 0 0?
Code
------------------
#include <iostream>
#include <iomanip>
#include <cmath>
using namespace std;
int main()
{
int num1, num2;
cout << fixed << showpoint <<
setprecision(2);
cout << "Enter two integers: ";
cin >> num1 >> num2;
cout << endl;
if (num1 != 0 && num2 != 0)
cout << sqrt(abs(num1 + num2)
+ 0.5) << endl;
else if (num1 != 0)
cout << floor(num1 + 0.5)
<< endl;
else if (num2 != 0)
cout << ceil(num2 + 0.5)
<< endl;
else
cout << 0 <<
endl;
return 0;
}
----------------------
Code Screenshot
----------------------
Code Output
---------------------
Code computes:
if both numbers not 0, the it outputs: sqrt(abs(num1 + num2) + 0.5)
if num2 = 0 and num1 != 0 output is floor(num1 + 0.5) << endl;
if num1 = 0 and num2 != 0 output is floor(num2 + 0.5) << endl;
if num1 = 0 and num2 = 0 output 0
-----------------
a. What is the output if the input is -23 8?
ANswer: 3.94
sqrt(abs(num1 + num2) + 0.5) = 3.94
-----------------
b. What is the output if the input is 12 32?
Answer: 6.67
sqrt(abs(num1 + num2) + 0.5) = 6.67
------------
c. What is the output if the input is 15 0?
Answer: 15
floor(num1 + 0.5) =15
------------
d. What is the output if the input is 0 -36?
Answer: -35
floor(num2 + 0.5) = -35
---------------
e. What is the output if the input is 0 0?
Answer: 0
-----------------
I hope this helps you,
Please rate this answer if it helped you,
Thanks for the opportunity
Get Answers For Free
Most questions answered within 1 hours.