C++


  CONDITIONAL INSTRUCTION „IF”

 if (condition) instruction;

 if (condition) instruction; else instruction;

 if (condition) {instructions} else {instructions};

In logical expressions we use comparison operators ==, !=, <, >, <=, >= (equal to, miscellaneous, smaller, larger, smaller or equal, larger or equal) and logic operators && (and) and || (or).
Examples:

   if (a>b) cout <<”The first number is greater than the second”;    else
   if (b>a) cout <<”The second number is greater than the first”;    else
   cout <<”The numbers are equal”;


   if ((a>=b) && (b>=c)) cout<< ”The first number is the highest”;


  CONDITIONAL INSTRUCTION „SWITCH”

This is a instruction that allows you to check multiple conditions without having to write multiple if instructions.
Example:

   srand(time(NULL)); // switching on the random generator
   los = rand() % 100 + 1; // random a number from 1 to 100
   switch (los)
   {
     case 11: cout<< ”You have won the car”; break;
     case 27: cout<< ” You have won the book”; break;
     case 35: cout<< ” You have won chewing gum”; break;
     default : cout<< ”You have not won anything!”;break;
   }