Simple C++ code dosnt work for a noob
Posted on 2007-04-05
Recently decided to dive into C++ again.
Can anyone tell me why this code doesnt work? It is supposed to validate that the user has entered a number between 2 and 15 and if not, have them re-enter it. I'm not familiar with using ! expressions. As simple as this code may seem I assure you, this isnt someones homework. ;) I just decided to get back into it since i installed Gcc on my ubuntu. I compiled this using a comand line in ubuntu edgy.
me@mylinux:g++ myapp.cpp -o test
using namespace std;
num = 0;
cout << "Please enter a number between 2 and 15: \n";
cin >> "num;
while (!(num >=2)&&(num<=16);
cout << "Good job!! You entered " << num << "\n";
If i typed this correctly it should produce a success no matter what number you enter.
also, if anyone knows a good C++ noob book that caters to gcc or G++, i would appreciate any reccomendations.