@coder1 why complixity while (int (option)>=49 && (int) option<=52
why not while(option >='1' && option<='4');
// Well cin goes through a failed stat ,and will goes on untill the error flag and buffer are reset.
// There is a solution for that ,by adding cin.clear();cin.ignore(); after your cin
also you must alter while(option <= 4 || option >= 1); with while(option <= 4 && option >= 1); otherwise dont expect to get out from your do while loop
Im sorry but i dont know the method you listed above
I just wanted to offer him an easy method to do it.
Thanks for the method it would be handy in many cases.
There is a logical issue. '4' is supposed to mean "exit". In the examples above, every invalid input does direct exit. A more intuitive UI would ignore every invalid input, and act only with the four allowed.
PS. An another recent thread has exactly the same issue of "allow only [1-4]".