Search C Program | nimishsoft@gmail.com

Number Pattern - 2

5
45
345
2345
12345


#include <stdio.h>

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

5 comments:

  1. #include
    int main(){
    int i,j,flag=4;
    int array[]={1,2,3,4,5};
    for(i=1;i<=5;i++){
    for(j=1;j<=i;j++){
    printf("%d ",array[flag] );
    if(flag<4){
    flag++;
    }
    }
    flag=flag-i;
    printf("\n");
    }
    }

    ReplyDelete
  2. how to understand logic between i and j loop ??

    ReplyDelete
    Replies
    1. take this a coordinates.....because you are working on a plane ....

      Delete
  3. Sir,can you please explain the logic of above programme?

    ReplyDelete
  4. I think....this help you out of your confusion.
    #include
    void main()
    {
    int i,j,m,n,k;
    printf("Enter the number of rows \n");
    scanf("%d"&n);
    //loop for numbers

    for(i=n;i>=1;i--)
    {
    m=i;
    for(j=n;j>=i;j--)
    {
    printf("%d",m);
    m++;
    }
    //loop for space

    for(k=n;k<i;k--)
    {
    printf(" ");
    }
    printf("\n");
    }
    }

    ReplyDelete