Sentinel Help

So I'm making this program to take the absolute value of any integer that I give it. So I can't really make a sentinel with an in int value because that would be counter intuitive. My professor wants us to use "q" as the sentinel, but every time I enter "q" it run into an infinite loop.

#include <iostream>
#include <iomanip>
#include <cmath>
#include <limits>

using namespace std;

int myABS(int, int&);

int main()

{
int num1,
abu = 0;
cout << "\n\n\n";

while(num1 != ){

cout << setw(10) << " " << "Enter an Integer. 'q' to quit: ";
cin >> num1;

myABS(num1, abu);
cout << endl;
cout << setw(10) << " " << "The Absolute Value of " << num1 << " is " << abu << endl;
}
return 0;
}

int myABS(int x, int& y){
y = abs(x);
return y;
}
You could read the input into a string and if it is == "q" exit, otherwise convert it to an int and get the absolute value.
I'll give it a shot Thomas and report back!
Topic archived. No new replies allowed.