Search C Program

Loading...

Number Pattern - 44

    1
   123
  12345
 1234567
123456789
 1234567
  12345
   123
    1

#include<stdio.h>

int main()
{
    int i, j, k;
    for(i=1;i<=5;i++)
    {
        for(j=i;j<5;j++)
        {
            printf(" ");
        }
        for(k=1;k<(i*2);k++)
        {
                printf("%d",k);
        }
        printf("\n");
    }
    for(i=4;i>=1;i--)
    {
        for(j=5;j>i;j--)
        {
                printf(" ");
        }
        for(k=1;k<(i*2);k++)
        {
                printf("%d",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


6 comments:

  1. #include
    int main()
    {
    int i,j,k,n,c;
    printf("\n Enter how many lines : ");
    scanf("%d",&n);
    for(i=1,c=1;c<=n;c++,i+=2)
    {
    for(j=1;j<=40-n-c;j++)
    {
    printf(" ");
    }
    for(j=1;j<=i;j++)
    {
    printf("%d",j);
    }
    printf("\n");
    }
    for(i=2*n-3,c=n-1;c>0;c--,i-=2)
    {
    for(j=40-n-c;j>0;j--)
    {
    printf(" ");
    }
    for(j=1;j<=i;j++)
    {
    printf("%d",j);
    }
    printf("\n");
    }
    return 0;
    }

    ReplyDelete
  2. #include
    void main()
    {
    int i,j,n;
    printf("Enter level: ");
    scanf("%d",&n);
    for(i=1;i<=n;i++)
    {
    for(j=n;j>i;--j)
    {
    printf(" ");
    }
    for(j=1;j<(i*2);++j)
    {
    printf("*");
    }
    printf("\n");
    }
    for(i=n-1;i>=1;i--)
    {
    for(j=n;j>i;--j)
    {
    printf(" ");
    }
    for(j=1;j<(i*2);++j)
    {
    printf("*");
    }
    printf("\n");
    }
    }

    ReplyDelete
  3. using only two for loop. if possible or not

    ReplyDelete
  4. #include

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

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

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

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

    printf("\n");

    }

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

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

    printf("\n");
    }

    return 0;
    }

    ReplyDelete