C++ examples for Statement:if
Use if statement to range check the value of an integer entered from the keyboard
#include <iostream> int main()//from ww w . j a v a2s . com { std::cout << "Enter an integer between 50 and 100: "; int value {}; std::cin >> value; if(value < 50) std::cout << "The value is invalid - it is less than 50." << std::endl; if(value > 100) std::cout << "The value is invalid - it is greater than 100." << std::endl; std::cout << "You entered " << value << std::endl; }