- 3

Write a program to print a given triangle

this is the output 1 01 101 0101 10101

14th Oct 2018, 10:44 AM
Jhalak Rajput
17 ответов
+ 5
modified from Anna's code ''' int n = 10; int i=0, j=0; while(i++<n) while(j++<i||printf("\n")*(j=0)) printf("%d", (i^j)&1^1); ''' try to understand it, and you can learn much more than just an answer
15th Oct 2018, 6:06 AM
Flandre Scarlet
Flandre Scarlet - avatar
+ 6
For the protocol: it wasn't me who broke the "don't post a code before OP shows an attempt to do it on their own" rule 👆 https://code.sololearn.com/cNQa42tn7Hal/?ref=app
15th Oct 2018, 5:49 AM
Anna
Anna - avatar
+ 5
think before you code you have to remember what you want to complete and know what you're doing tell me first, how do you want to create such a triangle? not expected "for" or "while" or any "method" but what rules do you find in the expected output unless do you know what to do can you decide with which method you can do it
14th Oct 2018, 5:07 PM
Flandre Scarlet
Flandre Scarlet - avatar
+ 3
Have you tried it yourself?
14th Oct 2018, 11:19 AM
qwerty
qwerty - avatar
+ 3
Yeah but post your attempt here
14th Oct 2018, 11:36 AM
qwerty
qwerty - avatar
+ 2
Try posting your code here and show me what problem you got.
14th Oct 2018, 11:28 AM
qwerty
qwerty - avatar
+ 1
#include <stdio.h> int main() { puts("1\n01\n101\n0101\n10101"); return 0; }
14th Oct 2018, 11:12 AM
qwerty
qwerty - avatar
0
I need with for loop
14th Oct 2018, 11:14 AM
Jhalak Rajput
0
yes I tried
14th Oct 2018, 11:20 AM
Jhalak Rajput
0
i didn't get this output
14th Oct 2018, 11:29 AM
Jhalak Rajput
0
What output did you get?
14th Oct 2018, 12:09 PM
Anna
Anna - avatar
0
1 01 -2-3-4 something like that
14th Oct 2018, 12:39 PM
Jhalak Rajput
0
I don't know exact coding of this output
14th Oct 2018, 12:41 PM
Jhalak Rajput
0
#Unknown Shadow thanks for your help that is exactly what I want
15th Oct 2018, 5:43 AM
Jhalak Rajput
0
thank you Flandre Scarlet
15th Oct 2018, 7:25 AM
Jhalak Rajput