Testing cin for non numeric, non zero,and non negative values and entering loop. Cannot see why the test for values <=0 portion is not working. it should output:
cout << "Invalid value input\n";
Thanks in advance for catching what is probably a silly error.
#include <iostream>
using namespace std;
int main()
{
unsigned int integer;
cout<< "Enter a non negative number greater than 0: ";
cin>> integer;
do
{
while(!cin || integer <= 0)//validation condition
{
cout << "Invalid value input\n";
cin.clear();
cin.ignore(200, '\n');
cout<< "Enter a non negative number greater than 0: ";
cin>> integer;
}
cout<< "Enter a non negative number greater than 0: ";
cin>> integer;
} while(integer !=1);
return 0;
}