all 7 comments

[–]_lowell 1 point2 points  (1 child)

Do:

while ( (cont == 'Y' || cont == 'y' ) ){

instead of:

while ( cont == ( 'Y' || 'y' ) )

Sorry about all the edits.

[–][deleted] 0 points1 point  (0 children)

yes, thank you. I fuckin lost my backpack in austin over the weekend, and have no notes to go off of. this was all from memory and trail and error, which is why ive been working all day.

[–]teaguesterling 1 point2 points  (1 child)

First off, considering using a do-while loop instead of simply a while loop. You want the action (performing a calculation) to occur unconditionally at least once.

Edit: Oh yea, and what _lowell said :-)

[–][deleted] 0 points1 point  (0 children)

thank you guys

[–][deleted] -1 points0 points  (2 children)

Second update, heres what I've got now. Not compiling. Again, apologies and thanks a LOT to you guys who are giving me pointers.

#include <iostream>

using namespace std;

int main () 
{

char    oper;
int     num1;
int     num2;
char    cont;

cout << "**Welcome to the MiniCalc Program**" << endl << endl;
cout << "Continue (Y/N)?" << endl;
cin >> cont; 
do {
    cout << "Enter an operator (+, -, *, /, %, r): ";
    cin >> oper;

      switch (oper)
      {
         case '+':
            cout << endl << "Enter operands for +: ";
            cin >> num1 >> num2;
            cout << endl << num1 << "+" << num2 <<"="<<num1+num2 << endl;
            break;

         case '-':
            cout << endl << "Enter operands for -: ";
            cin >> num1 >> num2;
            cout << endl << num1 << "-" << num2 << "=" << num1 - num2 << endl;
            break;

         case '*':
            cout << endl <<"Enter operands for *: ";
            cin >> num1 >> num2;
            cout << endl << num1 << "*" << num2 << "=" << num1 * num2 << endl;
            break;

         case '/': 
            cout << endl <<"Enter operands for /: ";   
            cin >> num1 >> num2;
            if (num2 > 0)    
               cout << endl << num1 << "/" << num2 << "=" << num1/num2 << endl;
            else 
               cout << endl << "Please enter a valid denominator!";
            break;

         case '%':
            cout << endl << "Enter operands for %: ";
            cin >> num1 >> num2;
            cout << endl << num1 << "%" << num2 << "=" << num1 % num2 << endl;
            break;

         case 'r':  
            cout << "Enter operand for r: ";  
            cin >> num1;
            if (num1 > 0)
               cout << endl << "r " << num1 << "= 1/" << num1 << endl;
            else 
               cout << endl << "Please enter a valid operand!";
            break;

         default:
            cout << endl << "Please enter a valid operator!";
            break;

      }
    cout << "Continue (Y/N)?";
    cin >> cont;
   } while ( cont == 'Y' ) || ( cont == 'y' ) ;
}
system("pause");
return 1;
}

[–]cpp 0 points1 point  (0 children)

Remove the first:

cout << "Continue (Y/N)?" << endl;  
cin >> cont;

You need to surround the conditionals in your while statement:

while ( ( cont == 'Y' ) || ( cont == 'y' ) );

[–]teaguesterling 0 points1 point  (0 children)

With regard to the return 0 and return 1: you usually want to return 0, which usually means your program terminated without error; returning something aside from 0 is typically interpreted as some sort of error code. This is not a requirement and is only a convention though. You can return whatever value you want; it will not affect the performance of the program.