Conditionals & Logic
Learn how to use conditionals and logic to build programs that generate different outcomes.
StartKey Concepts
Review core concepts you need to learn to master this subject
if
Statement
if
Statement
if (a == 10) {
// Code goes here
}
An if
statement is used to test an expression for truth.
- If the condition evaluates to
true
, then the code within the block is executed; otherwise, it will be skipped.
Conditionals & Logic
Lesson 1 of 2
What you'll create
Portfolio projects that showcase your new skills
Magic 8-Ball
We've learned a powerful tool in C++ — control flow! It's so powerful, in fact, that it can be used to tell someone's fortune.
Harry Potter Sorting Hat Quiz
Write a program that asks the user some questions and places them into one of the four Houses!
Rock, Paper, Scissors, Lizard, Spock
The Big Bang Theory Edition!
How you'll master it
Stress-test your knowledge with quizzes that help commit syntax to memory