Loop (Computer programming and utilization)

493 views 18 slides Oct 16, 2017
Slide 1
Slide 1 of 18
Slide 1
1
Slide 2
2
Slide 3
3
Slide 4
4
Slide 5
5
Slide 6
6
Slide 7
7
Slide 8
8
Slide 9
9
Slide 10
10
Slide 11
11
Slide 12
12
Slide 13
13
Slide 14
14
Slide 15
15
Slide 16
16
Slide 17
17
Slide 18
18

About This Presentation

Computer programming and utilization


Slide Content

MAYUR PATEL(150990119031) MEET PATEL(150990119032) PARTHIV PATEL (150990119033) PAVAN PATEL (150990119034) PINKAL PATEL (150990119035) TOPIC :- LOOP (mechanical Engineering; 2nd Sem ) Shroff S. R. Rotary Institute Of Chemical Technology SUB:-CPU

Content. [1] Introduction To Loop. [2] While Loop. [3] Do While Loop. [4] For Loop. [5 ] Nested Loop.

LOOP Loop are used to repeat particular set of statement upto some fixed iteration in c language. There Are Three types of loop : 1)while loop 2) do….while loop 3) for loop These loops are catagarized into entry control loop and exit control loop .

Entry control loop v/s Exit control loop Entry control loop The Condition is checked in the STARTING of the loop. Eg : For & while loop. Exit control loop The Condition is checked in the END of the loop. Eg : do while loop.

The while statement While loop is the entrycontrol loop in wich the condition is evaluated at the staring of the loop. The test condition is evaluated and if it is true,the body of the loop is exicuted.after execution of the body, the condition is again evaluated and if it is true,the body of the loop is exicuted again.this process continues until the test condition becomes false and the control is transferred out of the loop.

Syntax: while(condition) { Statement; }

condition statement F T The flowchart of while loop is as follows :

Example: i =1; While( i <=10) { Printf (“% d”,i ); ++I; }

do_while loop Do_while loop is the exit control loop in which the condition is evaluated at the end of the loop It is an exit controlled loop statement. The body of the loop of do statement is compulsorily executed for the first time. After executing once., at the end of the loop, the test condition in the while statement is evaluated. If the condition is true, the body of the loop is executed again and this process continuous until the condition becomes false.

Syntax: Do { statement; } While (condition);

The flow chart of the do…while loop is as follows: statement condition F T

Example: i =1; Do { Printf (“% d”,i ); ++I; }while( i <=10);

The for statement: It is also an entry-controlled loop. For loop is very dynamic loop in c language in which initilization,conditionand update is done in single statement.

Syntax: For(initialization; condition;update ) { statement; }

Example: For( i =1; i <=10; ++ i ) { Printf (“% d”,i ); }

Nested loop:- Loop within loop is known as nested loop In case of nested loop the inner loop is exicuted first then after complition of all the values of inner loop the outer loop is exicuted

Example:- for( i =1;i<=10;++ i ) For(j=1;j<=10;++j) { Printf (“% d%d”I,j ); }

THANK YOU
Tags