+ 1
How to make my programme reject floating point numbers within an if statement?
I want my programme to reject any floating point number input. Please show me your way...xd https://code.sololearn.com/cig2XjrnuRlW/?ref=app
3 odpowiedzi
+ 4
Take a float and check if it has decimal numbers by checking the equality with the number and its own floor. Then you convert it to an integer.
Anyway, I would suggest you making some advice when you are asking for the user input.
+ 1
By default if you use cin to put value into integer it "cuts" floating point numbers. So for example if you put 14.56 program will convert it into 14 and put it to your variable.
+ 1
But Is there a way to make the programme print "I didnt ask for a floating point number" if they so so?