C Program to Print 0-010-01010 Pyramid Number Pattern

/* Program to print 0-010-01010 */
#include<stdio.h>

/* Main function */
int main()
{
    int i, j, k, n;
    printf("Enter number of lines of pattern: ");
    scanf("%d", &n);

    for(i=1;i<=n;i++)
    {
        for(j=1;j<=n-i;j++)
        {
            printf(" ");
        }
        for(k=1;k<=2*i-1;k++)
        {
            printf("%d", (k+1)%2);
        }
        printf("\n");
    }

    return 0;
}

output

Enter number of lines of pattern: 10

         0
        010
       01010
      0101010
     010101010
    01010101010
   0101010101010
  010101010101010
 01010101010101010
0101010101010101010

 

Leave a Reply

Your email address will not be published. Required fields are marked *

https://atozonlinesolutions.com/wp-content/uploads/2017/03/logo_white.png
https://atozonlinesolutions.com/wp-content/uploads/2017/03/logo_white.png
About
Products
Subscribe

If you wish to receive our latest news in your email box, just subscribe to our newsletter. We won’t spam you, we promise!

    Applauz

    As the pioneer of the lean startup movement, APPLAUZ has dedicated it’s time to sharing effective business strategies that help new businesses and enterpreneurs put their money to work in the right way.

    Subscribe

    If you wish to receive our latest news in your email box, just subscribe to our newsletter. We won’t spam you, we promise!

      Applauz

      As the pioneer of the lean startup movement, APPLAUZ has dedicated it’s time to sharing effective business strategies that help new businesses and enterpreneurs put their money to work in the right way.

      Copyright by BOLD THEMES. All rights reserved.