I'm making a program and want to use an if statement to add a 0 to output if the numbers = 0-9. I know how to do an if statement like:

int number=0;
if (number==5){
cout << " whatever " << endl;
}
Is there any way to do somthing like this?

int number=0;
if (number==1-9){
cout << " whatever " endl;
Thankyou for the help, it is well apreciated!

Recommended Answers

All 2 Replies

Use a compound conditional like this:

if(number >0 && number < 10)

Logical AND - &&, Logical OR - ||, Logical Inversion - !

Some things you should get comfortable with.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.