Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

iOS Objective-C Basics (Retired) Functional Programming in C Conditionals

Stuck on a quiz

I'm stuck on this question: http://imgur.com/tJubor6

I've tried so many things but I can't seem to get it. Any help would be much appreciated thanks.

3 Answers

Aaron Arkie
Aaron Arkie
5,345 Points

You're looking at an "else-if" statement which goes a little something like this:

if(condition){ printf("statement1"); }

else if(condition){ printf("statement2"); }

else if(condtion){ printf("statement3"); }

else{ printf("no matching conditions");

}

So the first "if" statement is the first condition the computer will look at. If the condition does not match the computer will go to the next if or "else if" statement, and so on depending on how many "else if" statements you have. Lastly, the "else" statement is just a default statement if the answer does not match any conditions. I hope this helps, Good luck!

Charlie Hield
Charlie Hield
4,767 Points

Try reading about half way down the page on this article (under "Several if + else structures can be concatenated"...)

that doesn't make sense