Star Pattern in C
Q. Write a C program for Star pattern?
#include <stdio.h>
#include <conio.h>
void main()
{
int n, i, j;
clrscr();
printf("Enter number of rows: ");
scanf("%d", &n);
for (i = 0; i < n; i++)
{
for(j = 0; j < i+1; j++)
{
printf("*");
}
printf("\n");
}
getch();
}
Q. Write an algorithm to Star pattern in C?
1. Start
2. Read the integer `n` (number of rows) from the user
3. For `i` = 0 to `n-1` (outer loop for rows)
4. For `j` = 0 to `i` (inner loop to print stars)
- Print `"*"` (star character)
5. End inner loop
6. Print a new line character to move to the next row
7. End outer loop
8. End
Quickly Find What You Are Looking For
OnlineTpoint is a website that is meant to offer basic knowledge, practice and learning materials. Though all the examples have been tested and verified, we cannot ensure the correctness or completeness of all the information on our website. All contents published on this website are subject to copyright and are owned by OnlineTpoint. By using this website, you agree that you have read and understood our Terms of Use, Cookie Policy and Privacy Policy.
point.com