SlideShare a Scribd company logo
2
Most read
4
Most read
6
Most read
Nested Loops
By:
Adnan Ferdous Ahmed
•What is a loop?
•What is a nested loop?
•Loops used in nested loops
•Nested while loops
•Nested do…while loops
•Nested for loops
a loop is a sequence of
instructions that is
continually repeated
until a certain condition is
reached.
•A loop inside another loop
is called a nested loop.
Nested loops
 while loops may be nested, that is we
can put a while loop inside another
while loop.
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.
Nested loops
To print the following series:-
1
1 2
1 2 3
1 2 3 4
1 2 3 4 5
#include<stdio.h>
Int main()
{
int r=1,c=1;
while (r<=5)
{
c=1;
while(c<=r)
{
printf(“%d”,c);
c++;
}
printf(“n”)
r++;
}
return
}
Nested loops
Nested loops
#include<stdio.h>
int main()
{
int a;
do
{
printf(“Enter any number”);
scanf(“%”,&a);
if (a>=0)
printf(“Number is positive”);
else
printf(“Number is Negative”);
}
while(a!=0);
return 0;
}
Enter any number : 1
Number is positive
To print the following:-
Nested loops
Nested loops
#include<stdio.h>
int main()
{
int r,c,k=1;
for (r=1;r<=4;r++)
{
for (c=1;c<=r; c++)
{
printf(“%d”,k);
k++;
}
printf(“n”);
}
return 0;
}
To print the following:-
1
2 3
4 5 6
7 8 9 10
Any questions regarding this topic?

More Related Content

PPTX
Nested loops
PDF
Date and Time Module in Python | Edureka
PPTX
Types of Statements in Python Programming Language
PPTX
Exception Handling in Java
PPTX
Loops Basics
PPTX
Control_Statements_in_Python.pptx
PDF
Overview of python 2019
PPTX
Control structures in c++
Nested loops
Date and Time Module in Python | Edureka
Types of Statements in Python Programming Language
Exception Handling in Java
Loops Basics
Control_Statements_in_Python.pptx
Overview of python 2019
Control structures in c++

What's hot (20)

PPT
Functions in C++
PPTX
FLOW OF CONTROL-INTRO PYTHON
PPTX
Intro to Python Programming Language
PDF
Java conditional statements
PPTX
Advanced Python : Static and Class Methods
PPTX
Exception handling
PPTX
File Handling Python
PPTX
Iterarators and generators in python
PPTX
Polymorphism in java
PPTX
Operators and expressions in c language
PPT
Java interfaces
PPT
Operators in C++
PPTX
Interfaces in java
PPTX
Built in function
PPTX
If else statement in c++
PPT
Input and output in C++
PPTX
Tokens in C++
PDF
Python functions
Functions in C++
FLOW OF CONTROL-INTRO PYTHON
Intro to Python Programming Language
Java conditional statements
Advanced Python : Static and Class Methods
Exception handling
File Handling Python
Iterarators and generators in python
Polymorphism in java
Operators and expressions in c language
Java interfaces
Operators in C++
Interfaces in java
Built in function
If else statement in c++
Input and output in C++
Tokens in C++
Python functions
Ad

Similar to Nested loops (20)

PPTX
Nested Loops in C.pptx
PPTX
Presentation on nesting of loops
PDF
presentationonnestingofloops-110228071935-phpapp01.pdf
PDF
LOOP STATEMENTS AND TYPES OF LOOP IN C LANGUAGE BY RIZWAN
PPTX
Loop structures
PPT
Chapter06.PPT
DOCX
Nested Loops in C unit2.docx
PPTX
Decision Making and Looping
PPT
12 lec 12 loop
PDF
Chapter 12 Computer Science ( ICS 12).pdf
PPTX
Loop (Computer programming and utilization)
PPTX
Loops in c
PPTX
Loops in c
PPTX
Loop control structure
PPTX
Loop.pptx and the data of the provided technology
PDF
175035 cse lab-05
PPTX
C Programming Language Part 6
PPTX
control structures in c if switch for
DOCX
CMIS 102 Hands-On Lab Week 4OverviewThis hands-on lab all.docx
PPT
Mesics lecture 7 iteration and repetitive executions
Nested Loops in C.pptx
Presentation on nesting of loops
presentationonnestingofloops-110228071935-phpapp01.pdf
LOOP STATEMENTS AND TYPES OF LOOP IN C LANGUAGE BY RIZWAN
Loop structures
Chapter06.PPT
Nested Loops in C unit2.docx
Decision Making and Looping
12 lec 12 loop
Chapter 12 Computer Science ( ICS 12).pdf
Loop (Computer programming and utilization)
Loops in c
Loops in c
Loop control structure
Loop.pptx and the data of the provided technology
175035 cse lab-05
C Programming Language Part 6
control structures in c if switch for
CMIS 102 Hands-On Lab Week 4OverviewThis hands-on lab all.docx
Mesics lecture 7 iteration and repetitive executions
Ad

Recently uploaded (20)

PDF
Claude Code: Everyone is a 10x Developer - A Comprehensive AI-Powered CLI Tool
PDF
Raksha Bandhan Grocery Pricing Trends in India 2025.pdf
PDF
Softaken Excel to vCard Converter Software.pdf
PDF
Adobe Illustrator 28.6 Crack My Vision of Vector Design
PPTX
L1 - Introduction to python Backend.pptx
PPTX
Operating system designcfffgfgggggggvggggggggg
PDF
Upgrade and Innovation Strategies for SAP ERP Customers
PPTX
CHAPTER 2 - PM Management and IT Context
PDF
Audit Checklist Design Aligning with ISO, IATF, and Industry Standards — Omne...
PPTX
Agentic AI Use Case- Contract Lifecycle Management (CLM).pptx
PDF
Design an Analysis of Algorithms II-SECS-1021-03
PDF
Internet Downloader Manager (IDM) Crack 6.42 Build 42 Updates Latest 2025
PDF
Which alternative to Crystal Reports is best for small or large businesses.pdf
PDF
Understanding Forklifts - TECH EHS Solution
PDF
SAP S4 Hana Brochure 3 (PTS SYSTEMS AND SOLUTIONS)
PDF
System and Network Administration Chapter 2
PPTX
VVF-Customer-Presentation2025-Ver1.9.pptx
PDF
Why TechBuilder is the Future of Pickup and Delivery App Development (1).pdf
PPTX
Introduction to Artificial Intelligence
PPTX
Lecture 3: Operating Systems Introduction to Computer Hardware Systems
Claude Code: Everyone is a 10x Developer - A Comprehensive AI-Powered CLI Tool
Raksha Bandhan Grocery Pricing Trends in India 2025.pdf
Softaken Excel to vCard Converter Software.pdf
Adobe Illustrator 28.6 Crack My Vision of Vector Design
L1 - Introduction to python Backend.pptx
Operating system designcfffgfgggggggvggggggggg
Upgrade and Innovation Strategies for SAP ERP Customers
CHAPTER 2 - PM Management and IT Context
Audit Checklist Design Aligning with ISO, IATF, and Industry Standards — Omne...
Agentic AI Use Case- Contract Lifecycle Management (CLM).pptx
Design an Analysis of Algorithms II-SECS-1021-03
Internet Downloader Manager (IDM) Crack 6.42 Build 42 Updates Latest 2025
Which alternative to Crystal Reports is best for small or large businesses.pdf
Understanding Forklifts - TECH EHS Solution
SAP S4 Hana Brochure 3 (PTS SYSTEMS AND SOLUTIONS)
System and Network Administration Chapter 2
VVF-Customer-Presentation2025-Ver1.9.pptx
Why TechBuilder is the Future of Pickup and Delivery App Development (1).pdf
Introduction to Artificial Intelligence
Lecture 3: Operating Systems Introduction to Computer Hardware Systems

Nested loops

  • 2. •What is a loop? •What is a nested loop? •Loops used in nested loops •Nested while loops •Nested do…while loops •Nested for loops
  • 3. a loop is a sequence of instructions that is continually repeated until a certain condition is reached.
  • 4. •A loop inside another loop is called a nested loop.
  • 6.  while loops may be nested, that is we can put a while loop inside another while loop. 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.
  • 8. To print the following series:- 1 1 2 1 2 3 1 2 3 4 1 2 3 4 5 #include<stdio.h> Int main() { int r=1,c=1; while (r<=5) { c=1; while(c<=r) { printf(“%d”,c); c++; } printf(“n”) r++; } return }
  • 11. #include<stdio.h> int main() { int a; do { printf(“Enter any number”); scanf(“%”,&a); if (a>=0) printf(“Number is positive”); else printf(“Number is Negative”); } while(a!=0); return 0; } Enter any number : 1 Number is positive To print the following:-
  • 14. #include<stdio.h> int main() { int r,c,k=1; for (r=1;r<=4;r++) { for (c=1;c<=r; c++) { printf(“%d”,k); k++; } printf(“n”); } return 0; } To print the following:- 1 2 3 4 5 6 7 8 9 10
  • 15. Any questions regarding this topic?