Help me with this output. The output is shown below but not getting program how to do. | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Help me with this output. The output is shown below but not getting program how to do.

If user input n=2 then output show @ @**@ @**@ @ If user inputs n=4 then output will be @ @ @**** @ **** @ @ **** @ ****@ @ @ Help with me.

17th Oct 2019, 7:24 AM
PRINCE KUMAR
16 Answers
+ 3
put your code on code playground and link it here
17th Oct 2019, 8:20 AM
✳AsterisK✳
✳AsterisK✳ - avatar
+ 3
I think you missed a space in the first example. Here is a code making patterns: https://code.sololearn.com/cw1aqUXI5Iaz/?ref=app Edit: now the padding is exactly like in the question: no spaces in n=2 output.
18th Oct 2019, 8:55 PM
Victor
+ 3
No problem Bro. Next time you can try following approach: 1. find relations between input and pattern parameters: - number of lines (2n) - starting character: @ if line<=n+1, otherwise " " - ending character: @ if line>=n, otherwise " " - number of characters in line n+(n-1)*n/2 - offsets - padding 2. Make an outer loop for lines 3. Make inner loop(s) for characters in the line Another approach is to make a string variable and modify it to print each line
19th Oct 2019, 7:36 AM
Victor
17th Oct 2019, 10:53 PM
A͢J
A͢J - avatar
+ 2
PRINCE KUMAR You can place a mark on Victor's answer as a token of gratitude for his efforts working on the code, and his explanation clears how the pattern is formed.
19th Oct 2019, 8:11 AM
Ipang
+ 1
have you try writing some code for this, if(true) show it; else try write some, users here don't write code for others but help em fix it
17th Oct 2019, 8:05 AM
✳AsterisK✳
✳AsterisK✳ - avatar
+ 1
PRINCE KUMAR I understand you need help with how to solve this. But I'm having difficulty also trying to understand the pattern (about the padding and missing @ character), as I have asked in my earlier response (please see it). Until I'm seeing clearly how the pattern works, I'm afraid I can't suggest you anything (sorry).
17th Oct 2019, 11:06 AM
Ipang
+ 1
It is giving right answer bro
19th Oct 2019, 2:30 AM
Rishu Dubey
Rishu Dubey - avatar
0
Yes I have written # include<conio.h> # include<conio.h> void main() { int n,i,j,k=1,m; clrscr(); printf("enter no."); scanf("%d",&n); for(i=1; i<=n+1; i++) { for(m=i; m<=i; m++) { printf("@"); } for(j=1; j<k; j++) { printf(" "); } for(j=1; j<=n; j++) { printf("*"); } printf("\n"); k=k+(n-1); } getch(); }
17th Oct 2019, 8:06 AM
PRINCE KUMAR
17th Oct 2019, 8:34 AM
PRINCE KUMAR
0
I'm not understanding the pattern, when N = 2, the asterisks are printed without any padding. @**@ // no padding whatsoever @**@ But when N = 4, there's a padding to the left and/or right side of the asterisks. Shouldn't there also be a padding for the case N = 2? @**** @ **** @ // left/right padding @ **** @ // left/right padding ****@ // left padding And there's a missing '@' to the left and to the right for the case N = 4 @**** // missing right @ @ **** @ @ **** @ ****@ // missing left @ (Edited)
17th Oct 2019, 8:56 AM
Ipang
0
The output is correct but not getting how to built program
17th Oct 2019, 10:17 AM
PRINCE KUMAR
0
Ipang see question above
17th Oct 2019, 10:59 AM
PRINCE KUMAR
0
In case of n=2 When n=2 executes then @ runs 1 more means it prints @ three times And also Asterisk 3 times but with padding. Yes there is a padding on right as well as left also And in case of n=4 The output is correct. and also Asterisk start printing from middle of @
17th Oct 2019, 11:18 AM
PRINCE KUMAR
0
✳AsterisK✳ help me bro
17th Oct 2019, 1:48 PM
PRINCE KUMAR
0
Victor thanks bro
19th Oct 2019, 3:17 AM
PRINCE KUMAR