Search This Blog

Loading...

Number Pattern - C Program

/* C Program to print number pattern */

#include<conio.h>
#include<stdio.h>
void main()
{
    int i,j,n,k;
    clrscr();

    printf("\nEnter the no of lines to be printed: ");
    scanf("%d",&n);
    for(i=0;i<n;i++)
    {
       for(j=n-i;j>0;j--)
       {
   printf(" ");                       
//THIS CODE FOR PRINTING THE SPACES.
       }
       for(k=0;k<=i;k++)
       {
   if(k%2==0)
       printf("0");
   else
       printf("1");
       }
       printf("\n");
    }
    getch();
}



Output:
 Number pattern :3
  1
  12
  123
  1234

1 comment: