C Program to print binary numbers in a Right angled Triangle pattern
Program
#include<stdio.h>
void main()
{
int i, j, count = 1, num;
printf("Enter the number of rows to print:\t");
scanf("%d", &num);
for (i = 1; i <= num; i++)
{
for (j = 1; j <= i; j++)
{
printf("%d ", count % 2);
count++;
}
if (i % 2 == 0)
count = 1;
else
count = 0;
printf("\n");
}
}
Output
Enter the number of rows to print: 6
1
0 1
1 0 1
0 1 0 1
1 0 1 0 1
0 1 0 1 0 1