Wednesday, 20 March 2019

CP: Pattern Display - 2

Que: Write a C program to display the following different Patterns.
1
0 1
1 0 1
0 1 0 1


Code: 

#include <stdio.h>
int main(void) {
int i, j;

for (i = 0; i < 4; i++)
    {
       for (j = 0; j <= i; j++)
    {
        if (((i + j) % 2) == 0)
        {
            printf("1");
        }
        else
        {
                printf("0");
        }

printf(" ");

}

printf("\n");

}
return 0;

}

Logic: 

No comments:

Post a Comment

LAB 7 Arduino with Seven Segment Display || Arduino Tutorial || Code and Circuit Diagram || Project

  LAB 7 Arduino with Seven Segment Display || Arduino Tutorial || Code and Circuit Diagram || Project Dear All We will learn how to Connec...