vendredi 6 septembre 2019

How to take input of integer type and restrict the use of char and string type by asking user to input again using for loop

I wanna make a program in c++ in which I will use if statement to make a condition that the user should enter only integers from 0 to 50 and if the user tries to enter integers greater than 50 or lesser than 0 or user enters any other data type then he should be asked to enter again using for loop.

I have tried only one condition using if statement to limit the integer from 0 to 50 but my for-loop runs three times in a single step if the user enters an integer lesser than or greater than the above mentioned limit.

Aucun commentaire:

Enregistrer un commentaire