- 3
Write a program to print a given triangle
this is the output 1 01 101 0101 10101
15 Antworten
+ 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
+ 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
+ 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
+ 3
Have you tried it yourself?
+ 3
Yeah but post your attempt here
+ 2
Try posting your code here and show me what problem you got.
+ 1
#include <stdio.h>
int main()
{
puts("1\n01\n101\n0101\n10101");
return 0;
}
0
I need with for loop
0
yes I tried
0
i didn't get this output
0
What output did you get?
0
1
01
-2-3-4
something like that
0
I don't know exact coding of this output
0
#Unknown Shadow thanks for your help that is exactly what I want
0
thank you Flandre Scarlet