"C Program to Display a Star Square Pattern
Example
#include<stdio.h>
int main()
{
int row,j,nacr();
for(row=1;row<=10 ;row++)
{
for(j=1;j<=15;j++)
{
printf("*");
}
printf("\n");
}
getch();
}
"C Program to Display a Star Square Pattern
Explain Program
Step :1
#include<stdio.h>
- Standard Input Output library.
Step :2
int main()
- Entry point of the C program.
Step :3
int row, j, nacr();
- This line declares:
- int row:-> used as outer loop counter.
- int j:-> used as inner loop counter.
- nacr(); -> this function named nacr that returns int and takes unknown parameters.
Step :4
for(row = 1; row <= 10; row++)
- Outer loop that runs from row = 1 to 10.
- Controls how many lines will be printed.
Step :5
for(j = 1; j <= 15; j++)
- Inner
loop that prints asterisks on each line.
Step :6
printf("*");
- Prints one asterisk without a newline.
Step :7
printf("\n");
- After printing 15 stars, this moves the cursor to the next line.
Step :8
getch();
No comments:
Post a Comment