Saturday, 29 October 2011

C program to print pattern

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:
   *
   **
   ***

1 comment: