Search C Program

Loading...

Number Pattern - 26

5432*
543*1
54*21
5*321
*4321

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


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


2 comments:

  1. Hello,
    you have missed the later part i.e. printing after *.

    Below code is correct one.

    #include

    int main()
    {
    int i, j;
    int n;

    printf("Enter a number : ");
    scanf("%d", &n);

    for (i = 1; i <= n; i++)
    {
    for (j = n; j >= i; j--)
    {
    if (j == i)
    printf("*");
    else
    printf("%d", j);
    }

    for (; j >= 1; j--)
    {
    printf("%d", j);
    }
    printf("\n");
    }

    return 0;
    }

    ReplyDelete
  2. #include

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

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

    for(i=1;i<=r;i++)
    {
    for(j=r;j>=1;j--)
    {
    if(j==i)
    {
    printf("*");
    }
    else
    {
    printf("%d",j);
    }
    }
    printf("\n");
    }
    }

    ReplyDelete