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 i, j, bin;
printf("enter a value: ");
scanf("%d", &bin);
for (i = 0; i <= bin; i++)
{
for (j = 0; j <= i; j++)
{
if ((i + j) % 2 == 0)
{
printf("0 ");
}
else
{
printf("1 ");
}
}
printf("\n");
}
return 0;
getch();
}
OUTPUT
enter a value: 5
0
1 0
0 1 0
1 0 1 0
0 1 0 1 0
1 0 1 0 1 0
0 Comments