WAP to print pattern like "1 232 34543 4567654 567898765".


/*C program to print pattern like "1 232 34543 4567654 567898765"*/
#include<stdio.h>
#include<conio.h>
void main()
{
int n, c, d, num = 1, space;
printf("Enter a number\n");
scanf("%d",&n);
space = n - 1;
for ( d = 1 ; d <= n ; d++ )
{
num = d;
for ( c = 1 ; c <= space ; c++ )
printf(" ");
space--;
for ( c = 1 ; c <= d ; c++ )
{
printf("%d", num);
num++;
}
num--;
num--;
for ( c = 1 ; c < d ; c++)
{
printf("%d", num);
num--;
}
printf("\n");
}
getch();
}


Expected Output:
Enter a number
5
       1
     232
   34543
  4567654
567898765

Post a Comment

Previous Post Next Post