Tag Archives: #keepcoding

Calling functions.

In we need to know and maybe teach how to call a funtions. So, people who already have done WSQ08 without copy-paste, should know how to call functions.

Functions are called by their names. If the function is without argument, it can be called directly using its name, but for functions with arguments we have two ways to call it:

  1. Call by value
  2. Call by reference

I can see an example? Of couse! Here in my GitHub is my WSQ08 where I use functions and I called it into main function.

Calling functions.Calling functions.

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