AdnanFerdousAhmed
454 views
15 slides
Mar 21, 2018
Slide 1 of 15
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
About This Presentation
A presentation on nested loops of c program.
Size: 553.41 KB
Language: en
Added: Mar 21, 2018
Slides: 15 pages
Slide Content
Nested Loops
By:
Adnan Ferdous Ahmed
•What is a loop?
•What is a nested loop?
•Loops used in nested loops
•Nestedwhile loops
•Nested do…whileloops
•Nested forloops
aloopis a sequence of
instructions that is
continually repeated
until a certain condition is
reached.
•Aloopinside anotherloop
is called a nested loop.
while loops may be nested, that is we
can put a whileloop inside another
whileloop.
However, we must start the inner loop
after starting the outer loop and end the
inner loop before ending the outer loop for
a
logically correct nesting.
To print the following series:-
1
1 2
1 2 3
1 2 3 4
1 2 3 4 5
#include<stdio.h>
Intmain()
{
intr=1,c=1;
while (r<=5)
{
c=1;
while(c<=r)
{
printf(“%d”,c);
c++;
}
printf(“\n”)
r++;
}
return
}
#include<stdio.h>
intmain()
{
inta;
do
{
printf(“Enteranynumber”);
scanf(“%”,&a);
if(a>=0)
printf(“Numberispositive”);
else
printf(“NumberisNegative”);
}
while(a!=0);
return0;
}
Enter any number : 1
Number is positive
To print the following:-