Print pattern in c - number pattern -5

number-pattern

Print pattern in c - number pattern -5


Write a program to print following pattern

1
12
123
1234
12345

Program code

#include <stdio.h>

int main()
{
    int i, j;
    for(i=1;i<=5;i++)
    {
        for(j=1;j<=i;j++)
        {
            printf("%d",j);
        }
        printf("\n");
    }

    return 0;
}



Step by Step solution

1. Number of row -

   Is has 5row  , so first loop will execute for 5 time
#include <stdio.h>
int main()

{

    int i, j;

    for(i=1;i<=5;i++)
    
{......
 }



    return 0;

}


2. Number of character -

 It has only one type of character , so there will be only one nested loop
#include <stdio.h>
int main()

{

......
  for(j=1;j<=i;j++)
        {
            printf("%d",j);
        }
        printf("\n");
}


3.Number of column -

It has 5 maximum column and is decreasing with row number , so the nested loop decrease it's repetation with increase in row
#include <stdio.h>

............
      for(j=1;j<=i;j++)
        {
            printf("%d",j);
        }
        printf("\n");
...................


    return 0;

}


You can Browse related article below for more information and program code related to recursive function call

 Does above is helpful , Post you views in comment

DO NOT MISS OTHER C PROGRAMMING TUTORIAL

* indicates required






Comments

  1. 0317C84994B9
    Sosyal medya pazarlama stratejilerinde başarılı olmak için uygun fiyatlı ve güvenilir araçlar tercih edilmelidir. Bu noktada en ucuz smm panel seçenekleri işletmelerin bütçelerini zorlamadan geniş kitlelere ulaşmasını sağlar. Ayrıca kaliteli hizmet alarak organik büyüme sağlamak önemlidir ve bu nedenle doğru paneli seçmek büyük fark yaratır.

    ReplyDelete

  2. In the world of entertainment, finding a ücretli şov can provide a unique and memorable experience for audiences seeking quality performances. Whether you're interested in live acts or special events, there are numerous options available to suit different tastes and preferences. Many performers and organizers now offer exclusive shows that can be enjoyed from the comfort of your home or at designated venues. Exploring these opportunities can add excitement and variety to your entertainment choices. Ultimately, a ücretli şov often guarantees a level of professionalism and quality that free options might not always provide.

    ReplyDelete

Post a Comment

Popular posts from this blog

Copy Constructor

Print pattern in c - explore new perspectives in pattern printing

C++ Input/Output : Streams