WRITE A C PROGRAM TO PRINT THE PATTERN:
*
**
***
#include<stdio.h>
#include<conio.h>
void main()
{
int i,j,n;
printf("Enter the number of rows:");
scanf("%d",&n);
printf("The pattern is:\n");
for(i=1;i<=n;i++)
{
for(j=1;j<=i;j++)
{
printf("*");
}
printf("\n");
}
getch();
}
Output:
Enter the number of rows:3
The pattern is:
*
**
***
*
**
***
#include<stdio.h>
#include<conio.h>
void main()
{
int i,j,n;
printf("Enter the number of rows:");
scanf("%d",&n);
printf("The pattern is:\n");
for(i=1;i<=n;i++)
{
for(j=1;j<=i;j++)
{
printf("*");
}
printf("\n");
}
getch();
}
Output:
Enter the number of rows:3
The pattern is:
*
**
***
Here is an alternate C program to print right triangle star pattern in C.
ReplyDelete