Search C Program

Number Pattern - 34

             1
           2 3
         4 5 6
      7 8 9 10
11 12 13 14 15

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


Related Links:
- More Number Pattern Programs
- Star Pattern Programs in C
- Alphabet Pattern Programs in C
- Series Programs in C


5 comments:

  1. *
    *1
    **2
    ***3
    ****4
    Pls provide suitable solution

    ReplyDelete
    Replies
    1. int main()
      {
      int i, j;
      for(i=1;i<=5;i++)
      {
      for(j=1;j<=i;j++)
      {
      if(j<i || j==1)
      printf("*");
      else
      printf("%d",j-1);
      }
      printf("\n");
      }

      return 0;
      }

      Delete
  2. #include

    int main()
    {
    int i,j;
    int k=1;
    for(i=1;i<=5;i++)
    {
    for(j=5;j>=1;j--)
    {
    if(j<=i)
    printf("%d",k++);
    else
    printf(" ");
    }
    printf("\n");
    }
    return 0;
    }

    ReplyDelete
  3. #include

    int main()
    {
    int r,i,j,k;

    printf("Enter the no. of rows : ");
    scanf("%d",&r);

    for(i=1,k=1;i<=r;i++)
    {
    for(j=1;j<=r-i;j++)
    {
    printf(" ");
    }

    for(j=1;j<=i;j++,k++)
    {
    printf("%2d ",k);
    }

    printf("\n");
    }

    return 0;
    }

    ReplyDelete