promp the user for invalid input
1 2 3
|
float num;
cout<<"Enter Number: ";
cin>>num;
|
now what i need to is to display an invalid input if the user inputted a number with decimal.
You need to read number and display an error if it is not whole?
Check if number stays same after truncation:
1 2
|
if (num != std::trunc(num))
//ERROR
|
is it possible if i will not use math.h
if (num != static_cast<int>(num))
Topic archived. No new replies allowed.