Ask a Teacher



WRITE A PROGRAM TO GENERATE THE FOLLOWING PATTERN. 1 121 12321 1234321 123454321

#include<stdio.h>
 
main()
{
      int n, c, k, x = 1;
 
      scanf("%d", &n);
 
      for ( c = 1 ; c <= n ; c++ )
      {
          for ( k = 1 ; k <= c ; k++ )
          {
              printf("%d", x);
              x++;
          }
 
          x--;
 
          for ( k = 1 ; k <= c - 1 ; k++ )
          {
              x--;
              printf("%d", x);
          }
 
          printf("\n");
          x = 1;
      }
Note : Refer the above program and modify it.


comments powered by Disqus