4.2.3 Nested Loops
Let's carefully observe the general structure of a loop.
for (initialization; condition; increment/decrement)
{
Code to repeat
}
We can observe that Code to repeat could be any valid C language code. It can also be another for loop e.g. the following structure is a valid loop structure.
for(initialization; condition; increment/decrement)
{
for(initialization; condition; increment/decrement)
{
Code to repeat
}
}
When we use a loop inside another loop, it is called nested loop structure.
When do we use nested loops?
When we want to repeat a pattern for multiple times, then we use nested loops, e.g. if 10 times we want to display the numbers from 1-10. We can do this by writing the code of displaying the numbers from 1 -10 in another loop that runs 10 times.
Example
Social Media Links:
_____/❤ All Students are requested to Follow Me on Social Media!! ❤\_______
Instagram:➜ / digitaleduc. .
Twitter:➜ / shahbaz_ali101
Facebook Page:➜ / digitaleduca. .
Whatsapp:➜ https://chat.whatsapp.com/GqLGyGuZyNp...
Youtube:➜ https://bit.ly/32hA7C4?sub_confirmati...
10th Class Computer Science:
How to install and Download Code::Blocks:
https://bit.ly/3HuCBzO
10th Computer Science All Lectures Playlist:
https://bit.ly/3eYGMbb
10th Computer Science All Exercise Playlist:
https://bit.ly/3pMcoqu
10th Computer Science All Example Code Playlist:
https://bit.ly/3pKxxkK
10th Computer Science All Programming Time:
https://bit.ly/3eOmTmJ
10th Computer Science All Activities Playlist:
https://bit.ly/3eFQOh1
10th Computer Science All Programming Exercise Playlist:
https://bit.ly/3zltiQ6
9th Class Computer Science:
9th Computer Science Chapter 1:
https://bit.ly/3SCa6pR
9th Computer Science Chapter 2:
https://bit.ly/3SBi2I4
9th Computer Science Chapter 4:
https://bit.ly/3EfbEBT
9th Computer Science Chapter 4:
https://bit.ly/3EjLduP
9th Computer Science Chapter 5:
https://bit.ly/3SU0O8x
9th Computer Science All Exercise:
https://bit.ly/3EgNnvh
9th Computer Science All Activates:
https://bit.ly/3rrYppN
9th Computer Science Complete Lectures:
https://bit.ly/3t2BBhr
Timestamp
00:00 Intro
00:55 Recap
02:28 Nested Loop Structure
04:28 why do we use nested Loops?
04:43 Example 4.4
07:43 Outro
#Howtousenestedloop
#nestedforloop
#nestedforloops
#aloopinsideanotherloop
#repetitionstatementinc
#forloop
#whileloop
#dowhileloop
#typesofloop
#nestedloop
#twoloops
#nested
#loop
#dowhileloop
#nestedloopinc
#DigitalEducation
#DigitalEducationShahbazAli
#IntroductiontoProgramming
#LearnPythontheHardWay
#PythonCrashCourse
#IntroductiontoPython
#IntroductiontoJava
#IntroductiontoC
#IntroductiontoC
#ComputerGraphicsCourse
#IntroductiontoProgrammingLanguage
#IntroductiontoWebDevelopment
#CProgrammingCourse
#IntroductiontoCProgramming
#10thComputerChapter1
#10thComputerChapter2
#10thComputerChapter3
#10thComputerChapter4
#10thComputerChapter5
#10thComputer
#10thComputerChapter1Exercise
#10thComputerChapter2Exercise
#10thComputerChapter3Exercise
#10thComputerChapter4Exercise
#10thComputerChapter5Exercise
#10thComputerScience
#10thComputerPaper2022
#10thComputerPairingScheme2023
#10thComputerPaper2023
#10thComputerPairingScheme2023
#CLanguageTutorialforBeginners
#CLanguage
#CLanguageFullCourse
#CLanguageProgramming
#CLanguageCodewithHarry
#CLanguageFullCourseinHindi
#CLanguageBasics
#CLanguageTutorial
#CLanguageCourse
#CLanguageTutorialforBeginnersinHindi
#CLanguageinHindi
#CLanguageSaurabhShukla
#CLanguageProject
#CLanguagewithHarry
Computer Science 10th class
Lecturer of Computer Science
By Sir Shahbaz Ali
For any query or private tutoring contact (0309-0334424)
[email protected]