Basic Program Tasks Session 6



Back again with me, who as usual will post basic programming tasks using c ++ language If else, dan do while.
So, Check It out !!!


First I'll give you a little sense of If else and Do while.
If else
Sometimes when the condition in an if statement evaluates to false, it would be nice to execute some code instead of the code executed when the statement evaluates to true. The "else" statement effectively says that whatever code after it (whether a single line or code between brackets) is executed if the if statement is FALSE.

It can look like this:
if ( TRUE ) {
  // Execute these statements if TRUE
}
else {
  // Execute these statements if FALSE
}

C++ do while Loop
The do...while loop is a variant of the while loop with one important difference. The body of do...while loop is executed once before the test expression is checked.
The syntax of do while loop is:

do {
    // codes;
}
While {testexpression);


How do...while loop works?
-The codes inside the body of loop is executed at least once. Then, only the test    expression is checked.
-If the test expression is true, the body of loop is executed. This process continues until the test expression becomes false.
-When the test expression is false, do...while loop is terminated.


for example available below

1. Algorithm determines the largest number of 3 numbers














2. Algorithm determines the smallest number of 3 numbers


 











3. Algorithm determines the ideal weight (Quiz 1)














4. Algorithm specifies an odd or even number














Teşekkürler,
أراك المرة القادمة 






Comments