How to print
1
232
34543
4567654
567898765
Here is the simplified source code which will generate the pattern for the entered value of row provided by the user.
int main(){
int n,i,j,k,p;
printf("Enter no of row:\t");
scanf("%d",&n);
for(i=1;i<=n-1;i++)
{
k=i;
p=k;
for(j=1;j<=2*n-1;j++)
{
if((j>=n+1-i) && (j<=n-1+i)){
printf("%d",p);
if(k<2*i-1){
k++;
p=k;
}
else{
p--;
}
}
else
printf(" ");
}
printf("\n");
}
return 0;
}
output will look like:
0 comments: