How to write a C++ program when an integer is entered by user and checks whether it is greater than 8 and less than 10?

0 votes
asked by about Code::Blocks
edited by

write a C++ program when an integer is entered by user and checks whether it is greater than 8 and less than 10 or not and prints the results

1 Answer

0 votes
answered by (91.5k points)

To write a C++ program that checks if an entered integer is greater than 8 and less than 10, you can use the following code:

```cpp

include

int main() {
int number;
std::cout << "Enter an integer: ";
std::cin >> number;

if (number > 8 && number < 10) {
    std::cout << "The number is greater than 8 and less than 10." << std::endl;
} else {
    std::cout << "The number is not in the specified range." << std::endl;
}

return 0;

}
```

This program prompts the user to enter an integer, checks the condition, and prints the result accordingly.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
Anti-spam verification:
To avoid this verification in future, please log in or register
...