What is wrong in this programme? Since I want to print diamond of numbers. | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

What is wrong in this programme? Since I want to print diamond of numbers.

i.e. input n =5 Output should be like this 1 123 12345 123 1 https://code.sololearn.com/cu5I0x6V5NSx/?ref=app https://code.sololearn.com/cu5I0x6V5NSx/?ref=app https://code.sololearn.com/cu5I0x6V5NSx/?ref=app

2nd Jan 2020, 3:14 PM
Programmer
3 Answers
0
Give a space after number print. Like printf("%d ", a) ; And 2nd else part replace this.... else if(j>=(n+1)/2) { for (k=0;k<n;k++) { if(k<=j-(n+1)/2) printf (" "); else if(k<(n+1)/2 && k-j<=(n+1)/2) { printf ("%d ",a); a += 1; } If it not fit give a reply..
2nd Jan 2020, 7:27 PM
Jayakrishna 🇮🇳
0
Jayakrishna still this code is not printing diamond of number after correction as u mentioned
3rd Jan 2020, 2:15 AM
Programmer
0
It works with a space including as I mentioned... And it again ones check.. Programmer see this. https://code.sololearn.com/ctBXaHT5wYRF/?ref=app
3rd Jan 2020, 9:01 AM
Jayakrishna 🇮🇳