#include <iostream>
using namespace std;
int main()
{
int x, y, z;
char oper, rerun_choice = 'c';
while (rerun_choice == 'y');
{
cout<< " Welcome to the Calculator.\n";
cout<< " Input first number.\n";
cin>> x;
cout<< " Input + for addition, - for subtraction, * for multiplication, or / for division.\n";
cin>> oper;
cout<< " Input second number.\n";
cin>> y;
if ((oper) = '+')
{
z=x+y;
cout<<"The Answer is: "<<x<<"+"<<y<<" ="<<z<<".\n" ;
}
if ((oper) = '-')
{
z=x-y;
cout<<"The Answer is: "<<x<<"-"<<y<<"="<<z<<" .\n";
}
if ((oper) = '*')
{
z=x*y;
cout<<"The Answer is: "<<x<<"*"<<y<<" ="<<z<<".\n" ;
}
if ((oper) = '/')
{
z=x/y;
cout<<"The Answer is: "<<x<<"/"<<y<<"="<<z<<" .\n";
cout<<"The Remainder is: "<<x<<"%"<<y<<" .\n";
}
cout<<"continue ?";
cin>> rerun_choice;
}
return 0;
}
I have a couple questions....
1) why the rerun isnt working
2) when i run the program it is printing out all the equations for +,-,*,/ and also for % which i want to be the remainder
2b) the remainder is not coming out to be what i want.. instead its just plugging in the normal values for x and y and shoving % in the middle...
using namespace std;
int main()
{
int x, y, z;
char oper, rerun_choice = 'c';
while (rerun_choice == 'y');
{
cout<< " Welcome to the Calculator.\n";
cout<< " Input first number.\n";
cin>> x;
cout<< " Input + for addition, - for subtraction, * for multiplication, or / for division.\n";
cin>> oper;
cout<< " Input second number.\n";
cin>> y;
if ((oper) = '+')
{
z=x+y;
cout<<"The Answer is: "<<x<<"+"<<y<<" ="<<z<<".\n" ;
}
if ((oper) = '-')
{
z=x-y;
cout<<"The Answer is: "<<x<<"-"<<y<<"="<<z<<" .\n";
}
if ((oper) = '*')
{
z=x*y;
cout<<"The Answer is: "<<x<<"*"<<y<<" ="<<z<<".\n" ;
}
if ((oper) = '/')
{
z=x/y;
cout<<"The Answer is: "<<x<<"/"<<y<<"="<<z<<" .\n";
cout<<"The Remainder is: "<<x<<"%"<<y<<" .\n";
}
cout<<"continue ?";
cin>> rerun_choice;
}
return 0;
}
I have a couple questions....
1) why the rerun isnt working
2) when i run the program it is printing out all the equations for +,-,*,/ and also for % which i want to be the remainder
2b) the remainder is not coming out to be what i want.. instead its just plugging in the normal values for x and y and shoving % in the middle...
Comment