Search C Program

Loading...

Number Pattern - 23

12344321
123**321
12****21
1******1

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


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


7 comments:

  1. sir this is completely wrong...

    ReplyDelete
  2. yes..this is not working..second loop will never run!!

    ReplyDelete
  3. sorry for the above comment...the logic is absolutely correct...

    ReplyDelete
  4. It is perfect just in printf("*") instead of printf(" ") in both the cases

    ReplyDelete
  5. yes the code is crct only printf statmnt must be changed

    ReplyDelete
  6. #include

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

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

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

    for(s=1;s<=2*(r-i);s++)
    {
    printf("*");
    }

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

    ReplyDelete