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; }
4 odpowiedzi
+ 1
It is not printing the above pattern ..tell me where the modification is needed
+ 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
0
Thnx
- 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");
}