Its format is:
for (initialization; condition; increase) statement;
and its main function is to repeat statement while condition remains true, like the while loop.
Its format is:
for (initialization; condition; increase) statement;
and its main function is to repeat statement while condition remains true, like the while loop.
The do-while loop
Its format is:
do statement while (condition);
Its functionality is exactly the same as the while loop, except that condition in the do-while loop is evaluated after the exe
Iteration structures (loops)
Loops have as purpose to repeat a statement a certain number of times or while a condition is fulfilled.
The while loop
Its format is:
while (expression) stateme
Conditional structure: if and else
The if keyword is used to execute a statement or block only if a condition is fulfilled.
if and else
The if keyword is used to execute a statement or block only if a condition is fulfilled.
cin and strings
We can use cin to get strings with the extraction operator (>>) as we do with fundamental data type variables:
cin >> mystring;
However, as it has been said, cin extractio
The standard input device is usually the keyboard. Handling the standard input in C++ is done by applying the overloaded operator of extraction (>>) on the cin stream.
Until now, the example programs of previous sections provided very little interaction with the user, if any at all.
Conditional operator ( ? )
The conditional operator evaluates an expression returning a value if that expression is true and a different one if the expression is evaluated as false.