954,504 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

How do you make an if statment to several things?

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!

mercedesbenz
Newbie Poster
1 post since Oct 2008
Reputation Points: 10
Solved Threads: 0
 

Use a compound conditional like this:

if(number >0 && number < 10)

Lerner
Nearly a Posting Maven
2,382 posts since Jul 2005
Reputation Points: 739
Solved Threads: 396
 

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

Some things you should get comfortable with.

skatamatic
Posting Shark
959 posts since Nov 2007
Reputation Points: 403
Solved Threads: 129
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You