0% found this document useful (0 votes)
81 views

Looping Statement Are The Statements Execute One or More Statement Repeatedly Several Number of Times

Looping statements execute blocks of code repeatedly for a specified number of times. There are three types of loops in C: while loops, for loops, and do-while loops. Looping statements are useful when the same operations need to be performed multiple times, as they reduce the length and memory usage of code compared to writing out repetitive operations individually. Conditional statements only execute code once, whereas looping statements execute code repeatedly.

Uploaded by

Vijay Kumar
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
81 views

Looping Statement Are The Statements Execute One or More Statement Repeatedly Several Number of Times

Looping statements execute blocks of code repeatedly for a specified number of times. There are three types of loops in C: while loops, for loops, and do-while loops. Looping statements are useful when the same operations need to be performed multiple times, as they reduce the length and memory usage of code compared to writing out repetitive operations individually. Conditional statements only execute code once, whereas looping statements execute code repeatedly.

Uploaded by

Vijay Kumar
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 6

Looping statement

Looping statement are the statements execute one or more statement repeatedly several number of times.

Why use loop ?


When you need to execute a block of code several number of times then you need to use looping concept in C
language.

Advantage with looping statement

•Reduce length of Code

•Take less memory space.

•Burden on the developer is reducing.

•Time consuming process to execute the program is reduced.


Types of Loops.

There are three type of Loops available in 'C' programming language.

•while loop

•for loop

•do..while

Difference between conditional and looping statement

Conditional statement executes only once in the program

where as looping statements executes repeatedly several number of time.


While loop

In while loop First check the condition if condition is true then control goes inside the loop body

other wise goes outside the body. 

while loop will be repeats in clock wise direction.


Example of while loop

#include<stdio.h>
#include<conio.h>
void main() Output
{
int i;
clrscr(); 1
i=1;
while(i<5) 2
{
printf("\n%d",i);
3
i++; 4
}
getch();
}
For loop

for loop is a statement which allows code to be repeatedly executed.

For loop contains 3 parts Initialization, Condition and Increment or Decrements.


Example of for loop

#include<stdio.h>
#include<conio.h>
void main() Output
{
int i; 1
clrscr();
2
for(i=1;i<5;i++)
{ 3
printf("\n%d",i); 4
}
getch();
}

You might also like