Saturday, April 13, 2013

Pattern: 1 23 456 78910

Write a program to print 1
                                    23
                                    456
                                    78910




#include<stdio.h>
#include<conio.h>
int main()
{
    int a,b,c=1;
    for(a=1;a<=4;a++)
    {
        for(b=1;b<=a;b++)
        {
            printf("%d",c);
            c++;
        }
        printf("\n");
    }
}

16 comments:

  1. C++ Program to Print number pattern

    In c++ we can easily print any number patter just we need two for loop one inner loop for increment and decrements and other for line break.

    ReplyDelete
  2. If we do i++ instead of c++ what will we get?

    ReplyDelete
  3. How to make the pattern like
    1
    32
    654
    10987 and so on

    ReplyDelete
  4. Can someone make this for qbasic?

    ReplyDelete
  5. 2 4 6 8
    3 7 11 15
    4 10 16 22

    can u print this using 2 for loops

    ReplyDelete
  6. Solve this using two variable only

    ReplyDelete
    Replies
    1. this is 2 variable version

      int main()
      {
      int i=1,j=1;
      while(i<=10){
      printf("%d",i);
      if(i>=j*(j+1)/2){
      printf("\n");
      j++;
      }
      i++;
      }

      return 0;
      }

      Delete
  7. This comment has been removed by the author.

    ReplyDelete
  8. This comment has been removed by the author.

    ReplyDelete
  9. This comment has been removed by the author.

    ReplyDelete
  10. Print 123
    654
    789..any body please guys

    ReplyDelete