Вы находитесь на странице: 1из 19

3

1. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
2. while. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
3. do while. . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
4. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
5. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18

1.
, ,
- . , ,
.
0. .
1. .
2. .
3. .
4. .
5. .
6. .

, ,

, .
,
. , ,
.
.

0. .
1. .
2. .
3. .
4. .
5. .
6. 0.
7. .

, , ,
. , ,
, 7- .
, ,
,
.
- ,
.
, . !!!
,
,
.
: . ,
.
4

,
. while do while.

2. while
while
while()
{

}

1. .
2. , , .
3. ,
.
4.
, .
,
.
, . ,
,
.

.
, 7 .

. , .
Miracles.
#include <iostream>
using namespae std;
void main()
{
//

int ounter=0;
while(counter<7)//

{
ounter++;//
//
// ...
cout<<"You seen<<ounter<< miracle of world!!!\n;

}
cout<<"Now, you can start your work.\n";

}

.
1. 0
2.
. , ,
,
.
3. .
: ,

,
.
.
7

,
,
. , .
?! , ?

.
,
.
4. ,

.
5.
.
,
7.
You seen 7 miracle of
world!!!, .
7<7 .
Now, you can start your work..
:

. , .
while.

3. do while
do while:
do
{

}
while();

do while while.
, while
, , ,
. do while

. ,
, ,
while . , while do while
. :

10

do while
, ,

- . while,
do while. Calc.
#include <iostream>
using namespace std;
void main()
{
int answer,A,B,RES;


//

cout<<"\nSelect operation:\n";

cout<<"\n 1 - if you want to see SUM.\n";

cout<<"\n 2 - if you want to see DIFFERENCE.\n";

cout<<"\n 3 - if you want to exit.\n";

cin>>answer;

hile(answer!=3){ //
w
switch(answer){


case 1:
//

cout<<"Enter first digit:\n";

cin>>A;

cout<<"Enter second digit:\n";

cin>>B;

RES=A+B;

cout<<"\nAnswer: "<<RES<<"\n";

break; // switch


case 2:
//

cout<<"Enter first digit:\n";

cin>>A;

cout<<"Enter second digit:\n";

cin>>B;

RES=A-B;

cout<<"\nAnswer: "<<RES<<"\n";

break; // switch
case 3: //

cout<<"\nEXIT!!!\n";

break;


default:
//

cout<<"\nError!!! This operator isnt correct\n";
}

11

/
/


cout<<"\nSelect operation:\n";


cout<<"\n 1 - if you want to see SUM.\n";


cout<<"\n 2 - if you want to see DIFFERENCE.\n";


cout<<"\n 3 - if you want to exit.\n";
cin>>answer;
}
cout<<\nBye....\n;
}


. , , :
, , ,
.
, ,
.
.





//
cout<<\nSelect operation:\n;
cout<<\n 1 - if you want to see SUM.\n;
cout<<\n 2 - if you want to see DIFFERENCE.\n;
cout<<\n 3 - if you want to exit.\n;
cin>>answer;

.
do while.
. CalcDoWhile.

12

#include <iostream>
using namespace std;
void main()
{
int answer,A,B,RES;


do{ //





//

cout<<"\nSelect operation:\n";

cout<<"\n 1 - if you want to see SUM.\n";

cout<<"\n 2 - if you want to see DIFFERENCE.\n";

cout<<"\n 3 - if you want to exit.\n";

cin>>answer;

//
switch(answer){

case 1: //

cout<<"Enter first digit:\n";

cin>>A;

cout<<"Enter second digit:\n";

cin>>B;

RES=A+B;

cout<<"\nAnswer: "<<RES<<"\n";

break; // switch
case 2: //

cout<<"Enter first digit:\n";

cin>>A;

cout<<"Enter second digit:\n";

cin>>B;

RES=A-B;

cout<<"\nAnswer: "<<RES<<"\n";

break; // switch
case 3: //

cout<<"\nEXIT!!!\n";

break;


default:
//

cout<<"\nError!!! This operator isnt correct\n";
}

} while(answer!=3);
cout<<"\nBye....\n";

}

13

, ,

.
, .
, , .

.

14

4.
1.
.
,
1 5 . Summ.
.
#include <iostream>
using namespace std;
void main(){
int BEGIN=1; //
int END=5; //
int SUMM=0; //
int i=BEGIN; //

//

while(i<=END){ //( )

SUMM+=i;//

i++;//
}


//

cout<<"Result - "<<SUMM<<"\n\n";
}

.
, ,
:

15

, ,
.
:
, . ,
.
2.
.
,
5 . Line.
.

16

#include <iostream>
using namespace std;
void main(){

int COUNT=5; // ( )

int i=0; //

while(i<=COUNT){ //

cout<<"*";//
i++;//
}

cout<<"\n\n";
}

.
1. .
, i
*.
2. , i=5, *.
, !

17

5.
1. ,
. ,
, , .
2. ,
, .
3. n. ,

n (.. 0). .
n! = 1*2*3*....*n, ( n)
0! = 1 ( 0 1 ( ))

18