print Binary right angle triangle


Binary right angle triangle  

The binary number system consists of two different numerals, namely zero and one. These can be used to represent all other numbers. Let's see the program here,  

 

Program  

QUESTION:- binary right angle triangle 

1            OR      0 

0 1        OR       1 0 

1 0 1     OR       0 1 0  

0 1 0 1  OR       1 0 1 0 


  

#include <stdio.h>

#include <conio.h>

int main()

{

    int ijbin;

    printf("enter a value: ");

    scanf("%d", &bin);

    for (i = 0i <= bini++)

    {

        for (j = 0j <= ij++)

        {

            if ((i + j) % 2 == 0)

            {

                printf("0 ");
            }

            else

            {

                printf("1 ");
            }
        }

        printf("\n");
    }

    return 0;

    getch();
}


OUTPUT

enter a value: 5

1 0

0 1 0

1 0 1 0

0 1 0 1 0

1 0 1 0 1 0


Follow our page for regular updates.

0 Comments