How do ignore decimal numbers? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

How do ignore decimal numbers?

I want the the user to put a positive integer and i want it to ignore decimal numbers ,characterrs, and negative numbers

4th Feb 2017, 1:00 AM
Ulysis llanes
1 Answer
+ 5
You could use try and catch, if is not an integer the exception will take you to the catch part of the code, check this page for more information: http://www.cplusplus.com/doc/tutorial/exceptions/ hope it helps 😉
4th Feb 2017, 1:12 AM
C.E.
C.E. - avatar