Log in from a computer to take this course

You'll need to log in from a computer to start Learn C. But you can practice or keep up your coding streak with the Codecademy Go app. Download the app to get started.

apple storegoogle store

Congratulations on completing the lesson on conditionals! 🙌

Let’s review some of the major concepts from the lesson:

  • An if statement checks a condition and will execute a task if that condition evaluates to true.
  • if / else statements make binary decisions and execute different code blocks based on a provided condition.
  • We can add more conditions using else if statements.
  • Relational operators, including <, >, <=, >=, ==, and != can compare two values.
  • Logical operators, including &&, ||, and ! can allow multiple conditions in one conditional statement.
  • A switch statement can be used to simplify the process of writing multiple else if statements. The break keyword stops the remaining cases from being checked and executed in a switch statement.
  • A ternary operator can be used to simplify the process of an if else statement.



Optional: Little Mac is an interplanetary space boxer, who is trying to win championship belts for various weight categories on other planets within the solar system.

Write a space.c program that helps him keep track of his target weight by: It should ask him what his earth weight is. Ask him to enter a number for the planet he wants to fight on. It should then compute his weight on the destination planet.

Compile and execute:

gcc space.c ./a.out

Here is the table of conversion:

# Planet Relative Gravity
1 Mercury 0.38
2 Venus 0.91
3 Mars 0.38
4 Jupiter 2.34
5 Saturn 1.06
6 Uranus 0.92
7 Neptune 1.19

Take this course for free

Mini Info Outline Icon
By signing up for Codecademy, you agree to Codecademy's Terms of Service & Privacy Policy.

Or sign up using:

Already have an account?