Use of “if” conditional.

is about use conditional “if”. In order to write useful programs, we almost always need the ability to check
certain conditions and change the behavior of the program accordingly. Conditional
statements give us this ability. The simplest form is the if statement:

if (x > 0) {
  cout << "x is positive" << endl;
}

/* if (TRUE){

     cout << "The condition is true" << endl;

   }*/

This means that If it is true, then the statements in brackets get executed. If the condition is not true, nothing happens.

(The info before comes in the book at page 33: How to think like a computer scientist, C++ Version.)

 

Here is the link of my wsq05 where I used conditionals to make run the program. You can copy and paste in your editor and run it, to see how it works.

Use of

CC BY 4.0 Use of “if” conditional. by Gonzalo Mata is licensed under a Creative Commons Attribution 4.0 International License.

Comments are closed.