Conditionals

This lesson will teach you how to execute code selectively based on specified conditions by introducing the if, else if, else statements and the conditional operator.

One of the most important constructs in programming is the ability to execute (or not execute) pieces of code, or execute different pieces of code, depending on the outcome of some decision or question about data. The if-else construct lets us execute code selectively in C based on conditions defined by us.

If Statement

The basic if statement looks like this:

Create a free account to access the full course.

By signing up, you agree to Educative's Terms of Service and Privacy Policy