Plan: 1 For repetition operator
Download 61.79 Kb.
|
Mustaqil ishi
- Bu sahifa navigatsiya:
- 1 include 2 int main() 3 { 4 int i; 5 for ( i= 1; i 6 cout 7 cout
Working with examples reproducible process in C++. Plan: 1 For repetition operator 2 Do … while iteration operator 3 While iteration operator Depending on the problem to be solved, the programmer can use a repetition operator that is convenient for him. The syntax of the for iteration operator is as follows: for ( This operator starts the operation by performing The set of operators that must be performed during an iteration is called the iteration body. One or more operators can be used as the iteration body. If we want to use more than one operator in the iteration body, we need to enclose these operators in block {}. Example 1: A program that produces numbers from 1 to 10: 1 include 2 int main() 3 { 4 int i; 5 for ( i= 1; i <= 10; i++) 6 cout << i << " "; 7 cout << endl; 8 system ("pause"); 9 return 0; 10 } The following result is displayed on the screen: The following for the iteration operator is given in detail. The iteration operator for can be summarized as follows: for (initial_value_of_the variable; repeat_condition; increase the variable) repetition _tanas i; you can also reduce the variable instead of increase it. If you want to use more than one operator in the iteration body, we need to put the operators between the block {} (begin and end). Example 2: A program that produces numbers from 10 to 1: Download 61.79 Kb. Do'stlaringiz bilan baham: |
Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©fayllar.org 2024
ma'muriyatiga murojaat qiling
ma'muriyatiga murojaat qiling