Sign in to follow this  
Ghostwriter

If statements and conditions

Recommended Posts

Connect the two with a boolean AND operator, usually a && in most languages:

if ((n == 5) && (m == 8)) {
...
}

&& evaluates to true if both the conditions it connects evaluate to true.

Share this post


Link to post
Share on other sites
dunno if this is good programming practice or not,
but heres another way:

int someint = 2;
int someint2 = 4;

if(someint==2)
{
if(someint2==4)
{
// code will happpen if both conditions are true;
// same as if(someint==2 && someint2==4)
}
}






Fruny - fixed typo (= vs ==) and formatting.

Share this post


Link to post
Share on other sites
Quote:
Original post by supercrazy7474
dunno if this is good programming practice or not, but heres another way:


Depends on the context. Sometimes it may be a good idea, some time it may not be.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this