12th Class (HSSC-II) Computer SLO Based Key Point Notes
(National Book Foundation - As Federal Textbook Board, Islamabad Based on National Curriculum Pakistan 2023-2024 and Onward prescribed by Federal Board of Intermediate and Secondary Education, Islamabad, and All Pakistan Boards)
(National Book Foundation - As Federal Textbook Board, Islamabad
Based on National Curriculum Pakistan 2023-2024 and Onward prescribed by Federal Board of Intermediate and Secondary Education, Islamabad, and All Pakistan Boards)
{Contact WhatsApp # 03339719149 for Class-XII Computer Science Complete SLO-Based Key Points notes in pdf format as well as in PowerPoint Presentation for preparing/delivering the Lectures}
************************************
************************************
👉👉👉 Computer Science 12th Class Notes (Main Page)
************************************
Unit 4: Control Structures
4.2.7. Nested Loop
- A loop within another loop is called a nested loop.
- The loop that contains another loop in its body is called the outer loop.
- The loop used inside the body of the outer loop is called the inner loop.
- In a nested loop, the inner loop is completely executed for each iteration of the outer loop.
- Any loop can be placed inside the body of any other loop.
The general syntax of the nested loop is as follows:
Outer Loop
{
Inner Loop
{ }
}
{
Inner Loop
{ }
}
Working of nested loop
The nested loop is executed as follows:1. The condition given in the outer loop is evaluated. If the condition is TRUE, controls enter inside the body of the outer loop. Otherwise, the loop is terminated.
2. If body of outer loop contains any statement before the inner loop, it is executed.
3. The condition of inner loop is evaluated.
- When the condition is TRUE, the body of the inner loop is completely executed repeatedly until the given condition remains TRUE.
- When the condition of the inner loop is FALSE, the inner loop is terminated.
- If there is any statement after the body of inner loop, it is executed and then control transfers at the beginning of outer loop.
4. Steps 1 to 3 are repeated until the given condition of the outer loop remains TRUE.
Example # 1:
#include <iostream.h>#include <conio.h>
void main()
{
clrscr();
for (int i = 1; i<=2; i++)
{
cout<<“\n PAKISTAN”;
for ( int j=1; j<=3; j++)
{
cout<<“\n ZINDABAD”;
}
}
getch();
}
Example # 2:
Write a program that displays the following shape using nested for loops. *
* *
* * *
* * * *
* * * * *
* *
* * *
* * * *
* * * * *
#include <iostream.h>
#include <conio.h>
void main()
{
clrscr();
for (int i = 1; i<=5; i++)
{
cout<<“\n”;
for (int j = 1; j<=i; j++)
{
cout<<“ *”;
}
}
getch();
}
#include <conio.h>
void main()
{
clrscr();
for (int i = 1; i<=5; i++)
{
cout<<“\n”;
for (int j = 1; j<=i; j++)
{
cout<<“ *”;
}
}
getch();
}
👇👇👇👇👇👇👇👇👇
👇👇👇👇👇👇👇👇👇
************************************👉👉👉 Computer Science 12th Class Notes (Main Page)
************************************
Shortcut Links For:
1. 5th Class All Subjects Notes
2. 8th Class All Subjects Notes
3. Easy English Grammar Notes
1. Website for School and College Level Physics 2. Website for School and College Level Mathematics 3. Website for Single National Curriculum Pakistan - All Subjects Notes
© 2023 & onwards Academic Skills and Knowledge (ASK)
Note: Write me in the comments box below for any query and also Share this information with your class-fellows and friends.
1. Website for School and College Level Physics
2. Website for School and College Level Mathematics
3. Website for Single National Curriculum Pakistan - All Subjects Notes
0 Comments
Start Tuition (in Pakistan or Abroad) from Experienced Online Teachers.
Contact WhatsApp for tutoring and Assignment help on +923339719149