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 trialdarcyhegarty
1,177 PointsChain multiple if statements
I've tried combinations of else if and else to complete the following:
if ( i < 0 ){ printf("negative") } _____________ ( i > 0 ) { printf("positive"); } _____________ { printf("zero"); }
After rewatching the video, placing either ("else if", "else if") or ("else if", "else") as the answers should work, however I appear to be missing something.
2 Answers
Jason Anello
Courses Plus Student 94,610 PointsHi Darcy,
else if
and then else
worked for me. Maybe try again.
Misha Shaposhnikov
8,718 Pointsprintf is a C function. If you are using Objective-C, use
NSLog(@"Hello World");
NSLog(@"i = %d",i);
NSLog(@"pi = %f",3.14);
See the NSLog documentation for how to format integer, floating point, and object values. Remember to add the '@' symbol before the double quotes.
As far as the conditionals go, make sure that your 'i' variable is initialized. That's all I can say. Please describe in greater detail what exactly is not working so that we may know what to look for.