C language pattern solving 1 2 0 2 3 0 0 0 3 4 0 0 0 0 0 4 5 0 0 0 0 0 0 0 5 | Sololearn: Learn to code for FREE!
Novo curso! Todo programador deveria aprender IA generativa!
Experimente uma aula gr√°tis
0

C language pattern solving 1 2 0 2 3 0 0 0 3 4 0 0 0 0 0 4 5 0 0 0 0 0 0 0 5

#include <stdio.h> int main() { int i,j,k; for( i=1;i<=5;i++) k=i; { for(j=1;j<=9;j++) { if(j>=6-i&&j<=4+i) { if(j==6-i&&j==4+i) { printf("%d",k); k++;} else printf("0"); } else { printf(" "); } } printf("\n"); } return 0; }

8th Jul 2020, 8:50 AM
Suman Singh
Suman Singh - avatar
4 Respostas
+ 1
It is not printing the above pattern ..tell me where the modification is needed
8th Jul 2020, 8:51 AM
Suman Singh
Suman Singh - avatar
+ 1
your program lacks mobility since it doesn't take in inputs. try understanding the codes i've written instead. https://code.sololearn.com/cxAtdgZ6ED52/?ref=app
8th Jul 2020, 5:07 PM
Shen Bapiro
Shen Bapiro - avatar
0
Thnx
8th Jul 2020, 6:47 PM
Suman Singh
Suman Singh - avatar
- 1
Suman Singh this code gives you correct output, have a look for(i=0;i<=no_rows;i++) { for(j=0;j<=no_rows-i;j++) printf(" "); for(j=0;j<=i;j++) { if((j==0) || (j==i)) printf("%d ",i+1) ; else printf("0 "); } printf("\n"); }
14th Jul 2020, 1:59 PM
uday kiran
uday kiran - avatar