... while, for -
... , , ... ...
, , while for. ? , : 20 . (cout - ). :
1.cout << "Your name" << endl;
, 20 20 ! , 20 , , , 100 1000! , , . while for, ( ) , . , - , . , , 20, .. 20 . while.
: while
while
:
1.while ( )
2.{
3. 1;
4. 2;
5....
6. n;
7.}
. , , , :
01.// - while
02.
03.#include <iostream>
04.
05.using namespace std;
06.
07.int main()
08.{
09. int i;
10.
11. i = 1;
12. while (i <= 20)
13. {
14. cout << "Your name" << endl;
15. i = i + 1;
16. }
17.
18. return 0;
19.}
i, , . , , .. . , , ( return 0;). , ( i <= 20), i 21, . , , - , ( ). , ( ) :
1.i = i + 1;
( ) . : , (=) , , (=). , ( ) i 2, :
|
|
1.3 = 2 + 1;
, :
1.i++;
++ - .
while, .
! :
1. , ( {}), - , .
2. , .
3. ++ (++).
: while
while
while , while - . :
1.do
2.{
3. 1;
4. 2;
5....
6. n;
7.}
8.while ( ); //
!? , () while , .. , . while. while:
01.// - while
02.
03.#include <iostream>
04.
05.using namespace std;
06.
07.int main()
08.{
09. // 1
10. int i = 1;
11.
12. do
13. {
14. cout << "Your name" << endl;
15. i++;
16. }
17. while (i <= 20);
18.
19. return 0;
20.}
! :
1. while : . , . , . , .
2. while .
: for
, ++ - for. ? , () -, () , , . for :
1.for ( ; ; )
2.{
3. 1;
4. 2;
5......
6. n;
7.}
, , . :
01.// - for
02.
03.#include <iostream>
04.
05.using namespace std;
06.
07.int main()
08.{
09. for (int i = 1; i <= 20; i++)
|
|
10. {
11. cout << "Your name" << endl;
12. }
13.
14. return 0;
15.}
, . for , , . .