Follow This Blog For more... 😊

Program to print triangle Binary Pattern using 0 & 1 numbers for n number of lines.[Pattern:9]| Using C language| C Program series 30|

👨‍💻Program to print palindrome triangle Binary Pattern () using 0 & 1 numbers for n number of lines.[Pattern:9]

Code :

For n number of LINES:

    /*
    [Pattern:9]Program to print triangle Binary Pattern using 0 & 1 numbers for n number of lines.
    For Example:n=5
   
    1
    01
    101
    0101
    10101
   
    */
    #include<stdio.h>
    main()
    {
        printf("[Pattern:9]Program to print triangle Binary Pattern using 0 & 1 numbers for n number of lines.\n\n");
       
        int i,j,n,k=1;
        //Here,
        //n for number
        //i for row
        //j for colomn
       
        printf("Enter the number:");
        scanf("%d",&n);
       
        for(i=1;i<=n;i++)
        {
            if(i%2==0)
            {
                k=0;
            }
            else
            {
                k=1;
            }
            for(j=1;j<=i;j++,k++)
            {
                if(k%2!=0)
                {
                    printf("1");
                }
                else
                {
                    printf("0");
                }
            }
            printf("\n");
        }
    }

The output of Code:





👉Click for more C Program series Questions.[Questions list]

Comments

Popular Posts