Intro To C++/Making statement

Controlling with if and else
The C++ if keyword performs the basic conditional test. If something is true, then perform action. And it's syntax looks like this:

if(test-expression){statements-to-perform-when-true}

We could want the different action if that relationship is false. By appending else statement, it is possible.if-else statement looks like this:

if(test-expression){statements-to-perform-when-true} else{statements-to-perform-when-true}

Controlling with switch
When we have multiple case to check, using if-else statement repeatedly is not efficient.In this case, switch is more useful. The switch works in the different way. A given variable-value in parentheses try to find out a matching value among several case values in braces and execute the statements according to case value. Each statement finish with semicolon. Each value in braces finish with break;. break; let the switch block stop as the statement is executed and switch block satisfied the program. The switch syntax is as follows:

switch(variable-value){ case value1: statements-to-be-executed;break;  case value2: statements-to-be-executed;break;  ...................  case valuen: statements-to-be-executed;break;  default:statements-to-be-executed; }

Looping
A loop is a piece of code in the program that automatically repeat. The three type of loop in C++ programming are for loop, while loop and do while loop. The syntaxes are as following table:

Declaring & Defining Functions
In C++, a function is a group of code that provides some functionality to the program. When a function is called from the main program, the statements in a function are executed. Functions make program code easier and help working several programmer together. Tested functions can be reused. Each function needs to be declared at the start of the program. The syntax of a function prototype declaration is as follows:

return-data-type function-name(arguments-data-type list)

Function could be defined outside main function after declaration of function. The syntax of a function looks like this:

return-data-type function-name(arguments-data-type list){statements-to-be-executed}