 In our discussion of loops, we used conditions to determine whether a loop should continue or not. You also used conditions in an if statement to determine whether some action should be taken or not, as shown in this flow chart. Here's the generic model for an if statement in C. If some boolean expression evaluates to true, we do some statements in a block. If the condition is false, we don't do the statements. That's a bit abstract, so let's look at this program that asks the user for an integer. If the integer is even, the program prints a message to that effect. If the integer is a multiple of 7, it gives a message that says so. Let's say the user enters 18 as the number. The first condition to be tested is whether 18 mod 2 equals 0. Notice again that we have the two equal signs here. One equal sign means assigning a value to a variable. Two equal signs asks a question, true or false? Do these two things have the same value? In this case, the answer is true. 18 mod 2 is 0, which means we do this statement inside the block and print the message. C then proceeds to ask another question. True or false? Is 18 mod 7 the same as 0? In this case, the answer is false because 18 mod 7 is 4 and 4 is certainly not equal to 0. Because the condition is false, C doesn't do this statement inside the block and doesn't print the message. When we run the program, that's exactly what happens. What if the user gives us 21 as an input? The first condition will be false. 21 mod 2 is 1, not 0. And the message in the block won't be printed. The second condition is true. 21 mod 7 is 0. And the message in this block will be printed. Let's try it and see if that's what happens. And yes, that works also. If the user gives us 28 as the number, what happens? The first condition is true, which means that this message will be printed. The second condition is also true. 28 is divisible by 7 and we'll get the second message. And that's what happens. Finally, what happens if the user gives us a number like 19? 19 mod 2 is not equal to 0 and this message won't be printed from line 16. 19 mod 7 isn't 0 either and that means we won't get the print on line 20. We'll get no output from the program. And sure enough, that's what happens. This program used two instances of the one-way or unary if statement. While unary if statements are useful, it's much more common to ask a true-false question and do one thing if the answer is true and a different thing if the answer is false. Here's the generic model of such a statement in C. It's called an if-else statement. If the condition that we're testing is true, we do the statements in the first block. Otherwise, else, we do the statements in the else block. Let's put that to use in the age-in-days program. As the program is currently written, if you run the program and enter 0 or a negative number for the age, the program calculates the age-in-days even though the input really doesn't make any sense. Let's change the description of what the program does. We're going to ask for the age-in-years, and then if the age-in-years is greater than 0, we'll calculate the age-in-days and print it. Otherwise, we'll print an error message. Now let's make the change to the code. We're going to insert an if statement. If the years is greater than 0, this is what we want to do. We enclose it in a block in braces. Otherwise, we'll print a message that says, sorry, but age must be greater than 0. Let's rebuild and execute. If I give a positive number, I get the correct answer. And if I give a negative number, I get an appropriate error message. And those are the basics of using a unary if, and an if-else statement to make decisions in your C programs.