# Thread: if if vs if else

1. ## if if vs if else

I can't think of an example off hand. But is the difference between if if vs if else?

2. if if?

if you mean

if blah
if blah2

then im going to go with insane confusing logic being a problem

3. Right. What is the difference between say

if blah
if blah2

vs

if blah
else blah2

4. If I do understand what you're trying to say here...

A program will check the conditions of all if statements but only check the condition of an else (or else if) if the condition of it's corresponding if statement is false. There for making some instances of two if statements less efficient and in other cases will just yield improper results.

Code:
``` /*Consider this */

if (score > 100)
printf("You win a car.");
if (score > 50)
printf("You win a TV.");

/* Compared to this */

if (score > 100)
printf("You win a car.");
else if (score > 50)
printf("You win a TV.");```
The first example would yield a prize of a Car and a TV if someone scored over 100. The second example would only yield a Car with a score of over 100 and a TV with a score between 100-51.

Now, whatever this program is supposed to do is up to the consumer of the application, but this is an example of how two if statements and an if/else if statement could be different.

5. yea sounds about right ive wondered it before too but it never came out right on paper.

6. Yes, that was what I looking for. Thanks.