Plan: 1 For repetition operator


Download 61.79 Kb.
bet4/4
Sana23.09.2023
Hajmi61.79 Kb.
#1686133
1   2   3   4
Bog'liq
Mustaqil ishi

break; 
... 
case
;
break
default :


The iteration operator is true of the expression called "iteration condition"
value is greater than the number of operators (repeat body) in a particular part of the program
repeats times (iterative process).
Checking the iteration condition from performing operators on the iteration body
can be checked before (
for
,
while
repetitions) or in the body of the repetition
operators can be checked once executed (
do-while
for iteration operator
for
The syntax of the iteration operator is as follows:
for
(; < expression 2>;)
;
The while loop continues until the user enters a negative number. During each iteration, the number entered by the user is added to the sum variable.
When the user enters a negative number, the loop terminates. Finally, the total sum is displayed.
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 condition is checked.

Its syntax is:


do {
// body of loop;
}
while (condition);

Here,


  • The body of the loop is executed at first. Then the condition is evaluated.

  • If the condition evaluates to true, the body of the loop inside the do statement is executed again.

  • The condition is evaluated once again.

  • If the condition evaluates to true, the body of the loop inside the do statement is executed again.

Download 61.79 Kb.

Do'stlaringiz bilan baham:
1   2   3   4




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©fayllar.org 2024
ma'muriyatiga murojaat qiling