+ 4

Can anyone help me with a cpp program to input only int type?

The program should give error or text o/p that the input you gave is not an integer (if the input type is float,char,double etc)

10th Jan 2017, 3:09 PM
Navneet Sharma
Navneet Sharma - avatar
13 Answers
+ 3
@kenyatta Great ! Your code does the job but for character inputs, I mean, I just tried using a float input and it gives me the integer o/p. Thanks anyways. The code was great !
11th Jan 2017, 4:52 AM
Navneet Sharma
Navneet Sharma - avatar
+ 3
Yes, I did that only !
11th Jan 2017, 5:03 AM
Navneet Sharma
Navneet Sharma - avatar
+ 2
Yes exactly, Some senior asked me during my classes and he left me in suspense; I wonder if thats possible or not. 😅 (Everything is possible as, it is just a computer we can make it do almost anything).
11th Jan 2017, 4:57 AM
Navneet Sharma
Navneet Sharma - avatar
+ 2
@Kenyatta I made a program myself that takes the input and saved it as edit: string then it uses loop to check if there is a decimal or not, if found returns false.
11th Jan 2017, 4:59 AM
Navneet Sharma
Navneet Sharma - avatar
+ 2
@kenyatta I think this should work. As I don't know about this functions I an unable to understand and write proper code. Can yiu help me with a full program.(In your profile so I'd check it out). Thanks by the way.
11th Jan 2017, 5:26 AM
Navneet Sharma
Navneet Sharma - avatar
+ 1
Hello, Navneet You can see my codes They all are of int type except the last one That would help you Please like if you find my codes good
10th Jan 2017, 5:27 PM
Saksham Beniwal
Saksham Beniwal - avatar
+ 1
Thank You for your replies, but the solution I was expecting wasn't found.
10th Jan 2017, 5:34 PM
Navneet Sharma
Navneet Sharma - avatar