Pattern 38: C program to print the below number pattern on the console

Spread the love

Write a C Program to print below number pattern on the console:

Enter how many rows you want : 5
 1
 0 1
 0 1 0
 1 0 1 0
 1 0 1 0 1
Note: This program is one of the Series of Number pattern programs in C.

Program to print number pattern:

  1. #include<stdio.h>
  2. int main()
  3. {
  4.    int i,j,k,n;
  5.    printf(“Enter how many rows you want : “);
  6.    scanf(“%d”,&n);
  7.    k=1;
  8.    for(i=1;i<=n;i++)
  9.    {
  10.       for(j=1;j<=i;j++)
  11.       {
  12.          printf(” %d”,k);
  13.          k=!k;
  14.       }
  15.       printf(n);
  16.    }
  17.    return 0;
  18. }

Output:


Similar Number Patterns:

Similar Star pattern programs :

Venkatesh Macha

Hi Guys, I am Venkatesh Macha. I am a programmer and an Open Source enthusiast, Presently working as a Software Engineer. Apart from that, I love to explore new technologies and things.

You may also like...

Leave a Reply