diff options
author | smlckz <smlckz@college> | 2021-12-22 14:56:13 +0530 |
---|---|---|
committer | smlckz <smlckz@college> | 2021-12-22 14:56:13 +0530 |
commit | b73983c3717642ca10e7cfe93d97609adc377da9 (patch) | |
tree | a6e9fe4c27e3caa215f8aefa9265fb52f6de4375 /assignments/13-binary-pattern.c | |
download | college-b73983c3717642ca10e7cfe93d97609adc377da9.tar.gz |
backup
Diffstat (limited to 'assignments/13-binary-pattern.c')
-rw-r--r-- | assignments/13-binary-pattern.c | 65 |
1 files changed, 65 insertions, 0 deletions
diff --git a/assignments/13-binary-pattern.c b/assignments/13-binary-pattern.c new file mode 100644 index 0000000..5b3e4a9 --- /dev/null +++ b/assignments/13-binary-pattern.c @@ -0,0 +1,65 @@ +#include <stdio.h> + +int main(void) +{ + int i, j, h, f; + printf("Enter a height: "); + scanf("%d", &h); + for (i = 1; i <= h; i++) { + f = i % 2; + for (j = 1; j <= i; j++) { + printf("%d", f); + f = !f; + } + printf("\n"); + } + return 0; +} + +/* +Output: +Set 1: +Enter a height: 5 +1 +01 +101 +0101 +10101 + +Set 2: +Enter a height: 6 +1 +01 +101 +0101 +10101 +010101 + +Set 3: +Enter a height: 8 +1 +01 +101 +0101 +10101 +010101 +1010101 +01010101 + +Set 4: +Enter a height: 11 +1 +01 +101 +0101 +10101 +010101 +1010101 +01010101 +101010101 +0101010101 +10101010101 + + +*/ + |