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

I need help with this program, i need to modify it. Can some one show me step by

ID: 3866156 • Letter: I

Question

I need help with this program, i need to modify it. Can some one show me step by step how to do it?

/ to divide two numbers.
^ for the exponent x^y where x and y are the two numbers
q exit the program


2. Get the operation symbol (change to char from int) and verify that it is a valid operation symbol. Repeat the above step if it is not. Use a while loop until the user enters a valid operation.

3. Using your if-else structure, decide which operation to perform. If the user enters "q" for the operation, exit the program. Ask for the two operands (one only for the factorial) and verify they are valid - you can't divide by zero or take the negative factorial. Use while loop to repeat until the operands are correct.

4. Do the calculation and print out the results

5. Add a while loop surrounding the code your created above, keep repeating until the user enters 'q'. The structure of this code is almost identical to the structure you created for the guessing game though for this one, a do-while loop is a better choice than the regular while loop.

Implement the exponent operation with a for loops

If you used variables operand1 and operand2, compute the value of operand1^operand2. DO NOT USE THE LIBRARY FUNCTION FOR POWER (there is a function called "pow(parameter1, parameter2) in the math library but I want you to create the operation yourself).

You must support negative exponents. For example 2^2 is 4 and 2^(-2) is 0.25

To compute the exponent, use a for-loop. For example, to compute 3^4 by hand you would follow these steps

1. Start with 3^0 which is 1 (actually any number^0 is always 1)

2. Multiply 3*1 to get 3 (step 1)

3. Multiply 3 from the previous step - 3*3 to get 9 (step 2)

4. Multiply 9 from the previous step - 9*3 to get 27 (step 3)

5. Multiply 27 from the previous step - 27*3 to get 81 (step 4)

How many times did you multiply? How does that relate to 3^4? What was the starting value? What did you multiply? by the first operand or the 2nd operand?

For a negative exponent are you multiplying or dividing repeatedly?

# include using namespace std; int main() int a; int b; int add result; int sub result; float div result; int mul result cout

Explanation / Answer

#include <iostream>

#include <string>

#include <bits/stdc++.h>

using namespace std;

int main()

{

int a,b;

float result;

char choice;

int i;

cout<<"Enter two operands a and b,one value per line"<<endl;

cin>>a;

cin>>b;

while(1)

{

result=0;

cout<<"please enter"<<endl;

cout<<"+ for addition"<<endl;

cout<<"- for substration"<<endl;

cout<<"* fro multipliation"<<endl;

cout<<"/ for division"<<endl;

cout<<"^ for exponent x^y where x and y are give operands"<<endl;

cin>>choice;

if(choice=='+')

{

result=a+b;

cout<<" Addition of the given two numbers is "<<result<<endl;

}

else if(choice=='-')

{

result=a-b;

cout<<"Substration of the given two numbers is "<<result<<endl;

}

else if(choice=='*')

{

result=a*b;

cout<<"multipication of the given two numbers is "<<result<<endl;

}

else if(choice=='/')

{

result=a/b;

cout<<"division of the given two numberes is "<<result<<endl;

}

else if(choice=='^')

{

result=1;

if(b>0)

{

for(i=0;i<b;i++)

{

result=result*a;

}

}

else

{

for(i=b;i<0;i++)

{

result=result/a;

}

}

cout<<"Exponent value is "<<result<<endl;

}

else if(choice='q')

{

break;

}

}

}