m a
2010-03-07 23:30:05 UTC
#include
#include
using namespace std;
int main ()
{
int n1, n2, result;
char selc, sign;
result=0;
do
{
cout<<"Enter one of the following values:"<
cin>> selc;
switch (selc)
{
case '1':result= n1+n2;
sign='+';
break;
case '2': result= n1-n2;
sign= '-';
break;
case '3':result=n1*n2;
sign= '*';
break;
case '4': result=n1%n2;
sign= '%';
break;
case '9': return 1;
default: cout<<"Invalid selection, please try again."<
cout<<"Enter the first number: ";
cin>>n1;
cout<<"Enter the second number: ";
cin>>n2;
cout<<"The result of "<
while (selc != '9');
return 0;
}
the program works right, but when i come to do the math, its completely wrong, it gives me crazy numbers, anyone know how to fix this?
thanks in advance :)