Course Content
Detailed Content of Programming in C
0/1
Introduction
0/1
Structure of C program
0/1
Answers of ‘C’ Pointers Programs
0/1
About Lesson

Print a Pattern of Stars using Nested For Loops.

#include <stdio.h>

int main() {
int rows;

// Taking input for the number of rows
printf(“Enter the number of rows: “);
scanf(“%d”, &rows);

// Printing a pattern of stars using nested for loops
for (int i = 1; i <= rows; i++) {
for (int j = 1; j <= i; j++) {
printf(“* “);
}
printf(“n”);
}

return 0;
}