Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

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