Search C Program | nimishsoft@gmail.com

Number Pattern - 43

    1 
   1 2 
  1 2 3 
 1 2 3 4 
1 2 3 4 5

#include<stdio.h>

int main()
{
    int i,j;
    for(i=1;i<=5;i++)
    {
        for(j=5;j>i;j--)
        {
          printf(" ");
        }
        for(j=1;j<=i;j++)
        {
          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


17 comments:

  1. Replies
    1. seems working for me, checkout on codepad
      http://codepad.org/lsaZQvbx

      Delete
  2. Seriously !!!!!!!!!!!!!!!!
    the above program is wrong

    ReplyDelete
    Replies
    1. It working on codepad.com http://codepad.org/lsaZQvbx

      Delete
    2. the program is true dude

      Delete
  3. #include
    int main()
    {
    int i,j,s;
    for(i=1;i<=5;i++)
    {
    printf("\n");
    for(s=1;s<=5-i;s++)
    {
    printf(" ");
    }
    for(j=1;j<=i;j++)
    {
    printf("%d ",j);
    }
    }
    return 0;
    }

    ReplyDelete
  4. use this code to get the pattern correctly

    main()

    {
    int i,j,k;
    for(i=1;i<=5;i++)

    {
    for(int k=5;k>=i;k--)
    {
    System.out.print(" ");
    }
    for(j=1;j<=i;j++)
    {
    System.out.print(j);
    System.out.print(" ");
    System.out.print(" ");
    System.out.print(" ");
    }

    System.out.print("\n");
    }


    }

    ReplyDelete
  5. for (var i = 1; i <= n; i++) {
    for (var j = i; j <= n; j++) {
    result += " ";
    }
    for (var k = 1; k <= (i); k++) {
    result += c+" ";
    }
    result += "\n";

    }

    return result;

    ReplyDelete
  6. If you are using "Turbo C" then jst use **printf("%2d ",j);** instead of
    **printf("%d ",j);**

    ReplyDelete
  7. This program is 100℅ right

    ReplyDelete