# Learning C: lesson 2 Hello, this is Alexander.

Since I finally got an email from someone who liked m y previous lesson, I am going to make the second installment. This one will be about varia bles, and stuff like 'if' statements. 'IF' is the most important word in programming for many programs. Without it th ere is no conditional statements. This means that there can be only one way a program can execute. It would almost impossible to make a program without this one simple word. There are many things to understand when using IF statements. First, you must u nderstand stuff like OR NOT etc. This are the most important, so I will describe how to u se them in C and C++ programming below: (NOTE: ZERO IS FALSE! ONE IS TRUE!) NOT: This just says that the program should reverse the value...for example NOT( 1) would be 0. NOT(0) would be 1. NOT(any number but zero) would be 0. In C and C++ NOT i s written as - ! - just one simple little character. It is very useful and can save lots of time. AND: This is another important command, and it is used to say that if this AND t his is true... for example (1)AND(0) would come out as 0. (1)AND(1) would come out as 1. (ANY REAL NUMBER BUT ZERO)AND(0) would be 0. (ANY REAL NUMBER BUT ZERO)AND(ANY REAL NUMBER BUT ZERO) would be 1. The AND is written as - && - in C++. It is just two simple c haracters. OR: Very useful is the OR statement! For example (1)OR(0) would be 1! (0)OR(0) would be 0. (ANY REAL NUMBER)OR(ANY REAL NUMBER BUT ZERO) would be 1! It is simple, eit her one can be true and make the whole thing true. The OR is written as - in C++. It is also two simple characters. The next thing to learn is to combine them... What is !(1 && 0)? Of course, it would be 1. This is because 1 && 0 evaluates two 0 and ! 0 equals 1. Try some of these...they are not hard. If you have questions about them, you ca n email me at lallain@concentric.net. A. !(1 B. !(1 re OR) C. !((1 l) If you find you enjoy this you might want to look more at Boolean Algebra, which is also very helpful to programmers as it can be good for helping program conditional st 0) && 0) ANSWER: 1 (Parenthesis are usefu 0) 1 && 0) ANSWER: 0 ANSWER: 0 (AND is evaluated befo