Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write the missing statements in the following program so that it prompts the use

ID: 3732217 • Letter: W

Question

Write the missing statements in the following program so that it prompts the user to imput two numbers. If one of the numbers is 0 or negative, the program outputs that both numbers must be positive. If both the numbers are equal, it outputs the sum the numbers; if the first number is less than or equal to 2 and both the numbers are not equal, it outputs the second number to the power of the first number, otherwise, it outputs the product of the numbers. #include <iostream> using namespace std; int main () { double firstNum, secondNum; cout<< "Enter two nonzero numbers: "; cin >> firstNum>>secondNum; cout<< endl;

return 0;

}

Explanation / Answer

#include <iostream>
#include<cmath>
using namespace std;
int main ()
{
double firstNum, secondNum;
cout<< "Enter two nonzero numbers: ";
cin >> firstNum>>secondNum;
cout<< endl;
if(firstNum<=0||secondNum<=0)
cout<<"Both numbers must be positive";
else if(firstNum==secondNum)
cout<<"Sum of the numbers :"<<firstNum+secondNum;
else if(firstNum<=2 && firstNum!=secondNum)
cout<<"Second number to the power of first number :"<<pow(secondNum,firstNum);
else
cout<<"product of numbers :"<<firstNum*secondNum;

return 0;
}