We're sorry but this app doesn't work properly without JavaScript enabled. Please enable it to continue.

This lesson's interactive features are locked, please to keep using them

If Statements

if statements are the most basic form of control flow in C: very similar to other languages. Basic syntax:

if (x > 3) {
    printf("x is greater than 3\n");
}

if/else/else if are also available:

if (x > 3) {
    printf("x is greater than 3\n");
} else if (x == 3) {
    printf("x is 3\n");
} else {
    printf("x is less than 3\n");
}

Janky Syntax

You can write an if statement without braces if you only have one statement in the body:

if (x > 3) printf("x is greater than 3\n");

Buuuuut this shorthand is easy to mess up and in my opinion isn't worth saving a couple lines. There are enough ways to shoot yourself in the foot in C already.

Assignment

Take a look at exercise.h. Write the implementation for the function prototype found there back in exercise.c. It should calculate whether the given temperature is too cold or too hot (it's already in Fahrenheit of course, the most reasonable scale for regular living).

Do not add the \n to the end of the strings. That's done at print-time.