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

I am trying to figure out how to display \"ERROR\" after the equal sign when the

ID: 3627067 • Letter: I

Question


I am trying to figure out how to display "ERROR" after the equal sign when the user tries to divide by zero. The place where I have put the percent signs for now, it where I want "ERROR" to show up. How can I go about doing this? The normal thing that pops up there when I run the program is something like 1.#J and I don't know what that is.



else if (oper == '/')

cout << number1 << " / " << number2 <<" = "%%%%%%
<< number1 / number2 <<endl;



if (number2 == 0 )

cout << "Cannot divide by zero";
cout << endl;



system ("pause");
return 0;

}

Explanation / Answer

else if (oper == '/')
{

if (number2 == 0 )
cout << "Cannot divide by zero" << endl;

// u have to check before performing division opeariton....

else
cout << number1 << " / " << number2 <<" = "%%%%%% << (number1 / number2) <<endl;
system ("pause");
return 0;

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote