PF Lab6 Nested Loops EngUrdu
PF Lab6 Nested Loops EngUrdu
Urdu Explanation)
Program 1: Number Pattern Using Nested For Loop
Explanation (English)
This program prints a triangle pattern using nested for loops. The outer loop runs for each row
and the inner loop prints numbers from 1 to the current row number.
Explanation (Urdu)
Yeh program nested for loops ka use karke ek number triangle pattern print karta hai. Har outer
loop row ke liye chalta hai aur inner loop us row mein 1 se le kar us number tak values print
karta hai.
Code
#include <stdio.h>
int main() {
int i, j;
for (i = 1; i <= 5; i++) {
for (j = 1; j <= i; j++) {
printf("%d ", j);
}
printf("\n");
}
return 0;
}
Expected Output
1
12
123
1234
12345
Program 2: Multiplication Table Using Nested Loops
Explanation (English)
This program uses nested loops to display multiplication tables from 1 to 10. Each row shows
the multiples of a number.
Explanation (Urdu)
Yeh program nested loops ka use karta hai taake 1 se 10 tak ke multiplication tables print kiye ja
saken.
Code
#include <stdio.h>
int main() {
int i, j;
for (i = 1; i <= 10; i++) {
for (j = 1; j <= 10; j++) {
printf("%d x %d = %d\n", i, j, i*j);
}
printf("\n");
}
return 0;
}