Program to print Pyramid of Numbers.




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

Related Links :

83 comments:

  1. how to print this one
    1
    123
    12345
    1234567
    12345
    123
    1

    ReplyDelete
    Replies
    1. #include
      int main()
      {
      int r,s,st,n,m;
      int nst=n;
      printf("Enter a number");
      scanf("%d",&n);
      for(m=0;m<2;m++)
      {
      if(m==0){
      for(r=1;r0;r--)
      {
      for(s=n-r;s>0;s--)
      {
      printf("");
      }
      for(st=1;st<=2*r-1;st++)
      {
      printf("%d",st);
      printf(" ");
      }
      printf("\n");
      }
      }

      }
      }

      Delete
  2. how to print the following
    ------1
    ----2 --2
    ---3 -3 -3
    n so on...

    ReplyDelete
    Replies
    1. #include
      #include

      Void main()
      {
      int i,j,s;
      clrscr();
      for(i=1;i<=5;i++); // Maintains Rows
      {
      for(s=1;s<=5-i;s++); // Maintain Spaces
      {
      printf(" "); // Print One Space
      }
      for(j=1;j<=i;j++); // Maintains Columns
      {
      printf("%d",i);
      }
      printf("\n");
      }
      getch();
      }



      OUTPUT :
      ----------



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

      Delete
    2. ";
      }
      }
      $num=5;
      printstar($num);
      ?>

      Delete
  3. how to print the following
    ------1
    -----21
    ----321
    ---4321
    --54321

    ReplyDelete
  4. how to print
    1234567890
    1234 7890
    123 890
    12 90
    1 0

    ReplyDelete
  5. how to print
    ----4
    ---44
    --444
    -4444
    44444

    ReplyDelete
  6. how to print
    4444
    -444
    --44
    ---4

    ReplyDelete
  7. Dear friends if you Want any Solution Please Mail Me so that i will mail you solution, as i dont know ur E-Mail ID i cant help you...

    ReplyDelete
  8. how to print
    1
    1 2 1
    1 2 3 2 1
    1 2 3 4 3 2 1

    ReplyDelete
  9. how to print
    -------1
    -----1 2 1
    ---1 2 3 2 1
    -1 2 3 4 3 2 1

    ReplyDelete
  10. Please Give your E-Mail ID so that we will send you Solution by E-mail...Thanks...

    ReplyDelete
    Replies
    1. This comment has been removed by the author.

      Delete
    2. naseeb615@gmail.com
      pllxxx help me to make it ...
      Write a program that prints the following pattern where n is taken as input:

      n = 2

      1

      21

      n = 3

      1

      21

      321

      n = 4

      1

      21

      321

      4321

      And so on…

      Delete
  11. hiiii
    i want to make this program.

    1
    1 0 1
    1 0 0 0 1

    my id is gyanesh.niit@gmail.com

    ReplyDelete
  12. it has to be in pyramid only...so please help me out....

    ReplyDelete
  13. hiiii
    i want to make this program.

    ----1
    --1 0 1
    1 0 0 0 1

    my id is gyanesh.niit@gmail.com

    ReplyDelete
  14. how can we print this
    1
    0 1
    1 0 1
    0 1 0 1
    1 0 1 0 1
    plz send me on my id
    satan_bikalpa45@yahoo.com

    ReplyDelete
  15. how can we print this
    1
    0 1
    1 0 1
    0 1 0 1
    1 0 1 0 1
    plz send me on my id
    anshita.sharma@yahoo.co.in

    ReplyDelete
    Replies
    1. #include
      #include
      void main()
      {
      int i,j,k;
      for(i=1;i<=5;i++)
      {
      if(i%2==0)
      {
      k=1;
      }
      else
      {k=0;}
      for(j=1;j<=i;j++)
      {
      if (k==1)
      {
      k=0;
      }
      else
      {k=1;}
      cout<<k;
      }
      cout<<endl;
      }
      getch();
      }

      Delete
  16. -------1
    -----1 2 1
    ---1 2 3 2 1
    -1 2 3 4 3 2 1

    can anyone help me to print this..
    ma email id is lakshmi.saki@gmail.com

    ReplyDelete
  17. how to print
    1
    12
    123
    1234
    12345

    ReplyDelete
  18. #include
    #include
    void main()
    {
    int c=0,i,j,n;
    clrscr();
    printf("Enter The Number of lines to be created....");
    scanf("%d",&n);
    printf("\n............................................");
    for(i=0;i<=n;i++)
    {
    printf("\n");
    for(j=0;j<i;j++)
    {
    c=c+1;
    printf(" %2d",c);
    }
    }
    getch();
    }

    Output:-
    Enter The Number Of Lines To be created...5
    ............................................
    1
    2 3
    4 5 6
    7 8 9 10
    11 12 13 14 15

    ReplyDelete
    Replies
    1. #include
      int main()
      {
      int r,s,st,n,m=1;
      int nst=n;
      printf("Enter a number");
      scanf("%d",&n);
      for(r=1;r<=n;r++)
      {
      for(s=1;s<=n-r;s++)
      {
      printf("");
      }
      for(st=1;st<=r;st++)
      {
      printf("%d",m++);
      printf(" ");
      }
      printf("\n");
      }
      }

      Delete
  19. i tried the following program

    #include
    #include
    void main()
    {
    int c=0,i,j,n;
    clrscr();
    printf("Enter The Number of lines to be created....");
    scanf("%d",&n);
    printf("\n............................................");
    for(i=0;i<=n;i++)
    {
    printf("\n");
    for(j=0;j<i;j++)
    {
    c=c+1;
    printf(" %2d",c);
    }
    }
    getch();
    }


    but i am getting the output as
    1
    2
    3
    4
    5
    6

    instead of

    1
    23
    456
    78910

    any one please send me the program to my mail id.
    vamsimanoj29@gmail.com

    ReplyDelete
  20. hi i want code for follwing output
    1
    23
    456
    78910
    can any one provide my email id is chandankumar48968@gmail.com

    ReplyDelete
  21. hi i want code for following output
    1
    232
    34543
    4567654
    567898765
    can any one provide to my email id hemaa.cse@gmail.com

    ReplyDelete
  22. * * * * *
    * * * *
    * * *
    * *
    *
    * *
    * * *
    * * * *
    * * * * *
    how to print this?

    ReplyDelete
  23. 1
    1 2 1
    1 2 3 2 1
    1 2 3 4 3 2 1
    1 2 3 4 5 4 3 2 1

    can u please let me know how to print this in C++? thanks alot (nimashi_p@hotmail.com)

    ReplyDelete
  24. How to print the following>?? can anybody help???


    1
    2 3
    4 5 6
    7 8 9 10
    11 12 13 14 15
    16 17 18 19 20 21

    ReplyDelete
    Replies
    1. #include
      int main()
      {
      int r,s,st,n,m=1;
      int nst=n;
      printf("Enter a number");
      scanf("%d",&n);
      for(r=1;r<=n;r++)
      {
      for(s=1;s<=n-r;s++)
      {
      printf("");
      }
      for(st=1;st<=r;st++)
      {
      printf("%d",m++);
      printf(" ");
      }
      printf("\n");
      }
      }

      Delete
  25. how to print
    1
    1 2 1
    1 2 3 2 1
    1 2 3 4 3 2 1


    my email is rahults87@gmail.com

    ReplyDelete
  26. How to print
    1
    2 3 2
    3 4 5 4 3
    4 5 6 7 6 5 4
    5 6 7 8 9 8 7 6 5

    &

    * * * * * * *
    * * * 0 * * *
    * * 0 0 0 * *
    * 0 0 0 0 0 *

    ReplyDelete
  27. How to print this in c#
    1
    2 3 2
    3 4 5 4 3
    4 5 6 7 6 5 4
    5 6 7 8 9 8 7 6 5

    &

    * * * * * * *
    * * * 0 * * *
    * * 0 0 0 * *
    * 0 0 0 0 0 *

    my Email id:- mailtoprachi_patil@rediff.com

    ReplyDelete
  28. how to print
    1 2 3 4 5
    1 2 3 4
    1 2 3
    1 2
    1

    ReplyDelete
  29. how to print
    1 2 3 4 5
    1 2 3 4
    1 2 3
    1 2
    1

    ReplyDelete
    Replies
    1. #include
      #include
      main()
      {
      int i,j;
      clrscr();
      for(i=5;i>=1;i--)
      {
      for(j=1;j<=i;j++)
      {
      printf("%3d",j);
      }
      printf("\n");
      }
      getch();
      }

      Delete
    2. #include
      int main()
      {
      int r,s,st,n,m=1;
      int nst=n;
      printf("Enter a number");
      scanf("%d",&n);
      for(r=n;r>0;r--)
      {
      for(s=n-r;s>0;s--)
      {
      printf("");
      }
      for(st=1;st<+r;st++)
      {
      printf("%d",st);
      printf(" ");
      }
      printf("\n");
      }
      }

      Delete
  30. I want the coding for the following output:

    1
    121
    12321

    plz reply on this id : zip_zap997@yahoo.com

    ReplyDelete
  31. -------1
    -----1 2 1
    ---1 2 3 2 1
    -1 2 3 4 3 2 1

    can anyone help me to print this..
    ma email id is "chilly_eng@yahoo.com"

    ReplyDelete
  32. hi can u plz tell how to print foll
    1
    1 2 A
    1 2 3 A B
    1 2 3 4 A B C
    my email ID is shineg99@ymail.com

    ReplyDelete
  33. o/p:
    *****
    ****
    ***
    **
    *
    *
    **
    ***
    ****
    *****

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

    ReplyDelete
  34. how to create this one
    1
    23
    456
    78910

    my email is jayrichbausa@ymail.com

    ReplyDelete
  35. anybody please help........

    ReplyDelete
  36. please help me how to generate this pattern:
    4321
    321
    21
    1

    my email address is lc_111190@rocketmail.com

    ReplyDelete
    Replies
    1. IF ANY ONE GET SOLUTION PLZ SEND TO ME ALSO.
      ID IS ASACHAN2707@GMAIL.COM

      Delete
  37. how to print dis:
    123
    894
    765

    ReplyDelete
    Replies
    1. #include
      int main()
      {
      int a[10][10]={0},i,j,low=0,top=9,n=1;
      for(i=0;i<5;i++,low++,top--)
      {
      for(j=low;j<=top;j++,n++)
      a[i][j]=n;
      for(j=low+1;j<=top;j++,n++)
      a[j][top]=n;
      for(j=top-1;j>=low;j--,n++)
      a[top][j]=n;
      for(j=top-1;j>low;j--,n++)
      a[j][low]=n;
      }
      printf("\t\t\t\tPerfect Square\n");
      for(i=0;i<10;i++)
      {
      printf("\n\n\t");
      for(j=0;j<10;j++)
      {
      printf("%6d",a[i][j]);
      delay(300);
      }
      }
      return 0;
      }

      Delete
  38. hoe to get this one using while?

    *
    ***
    *****
    *******
    *********
    ***********

    pls email me scorpiotrisha09@yahoo.com
    plz help me asap

    ReplyDelete
  39. 3 digit number 123=1+2+3=6
    i want to make program for adition of 3digit no like this
    my email id is siddharthbhatt666@gmail.com

    ReplyDelete
    Replies
    1. IF YOU WANT LIKE DIS

      : 153 = 1*1*1 + 5*5*5 + 3*3*3


      #include
      using namespace std;
      int main()
      {
      int armstrong=0,num=0,result=0,check;
      cout<<"Enter Number to find it is an Armstrong number?";
      cin>>num;
      check=num;
      for(int i=1;num!=0;i++){
      armstrong=num%10;
      num=num/10;
      armstrong=armstrong*armstrong*armstrong;
      result=result+armstrong;
      }
      if(result==check){
      cout<<check<<" is an Armstrong Number";
      }
      else{
      cout<<check<<" is NOT an Armstrong Number";
      }
      return 0;
      }

      Delete
  40. how to print 1 as one and 2 as two ........upto n nos in c or c++

    ReplyDelete
  41. how to create this one ???????????
    1
    2 3
    4 5 6
    7 8 9 10
    plz do mail to arjunkneworld@gmail.com

    ReplyDelete
  42. what about this one

    -----*
    ----*-*
    ---*---*
    --*-----*
    -*-*-*-*-*

    ReplyDelete
  43. how to print
    1
    2 2 2
    3 3 3 3 3
    4 4 4 4 4 4 4

    ReplyDelete
  44. Plz print this by using loops in c:
    1
    2 3
    4 5 6
    7 8 9 10
    send by mail plz.mail id is 'deepu.kashyap@hotmail.com'

    ReplyDelete
  45. #include
    #include
    void main()
    {
    int i, j, k, c = 5;
    for (i = 1; i <= 5; i++)
    {
    /* k is taken for spaces */
    for (k = 1; k <= c; k++)
    {
    /* blank space */
    printf(" ");
    }
    for (j = 1; j <= i; j++)
    {
    /* %2d ensures that the number is printed in
    two spaces for alignment and the numbers are printed in the order. *
    printf("%2d", i);
    }
    printf("\n");
    /*c is decremented by 1 */
    c--;
    }
    return 0;
    }

    ReplyDelete
  46. You are asked to write a C++ program that reads a positive integer, greater than zero, from the user and then outputs a triangle of stars and numbers. The size of the triangle depends on the integer entered by the user. The first three rows should always be the same as in the example below (you have to find a suitable formula to print them) and again the rest of rows have numbers as in the example below.
    Example, if the user enters the number 5 as input, the following triangle appears on the screen:
    1
    1 2
    1 2 3
    4 4 4 4
    5 5 5 5 5

    i am supposed to write a program with this structure:

    while( )
    {
    if( )
    {while or do loop ( )}
    else
    {while or do loop ( )}

    my email is mac_mac4@hotmail.com

    plz hurry i have to turn in my work :(

    ReplyDelete
  47. o/p
    1
    1 2 1
    1 2 3 2 1

    #include
    #include
    main()
    {
    int i, j, k, space, n; // Decleare Variable
    clrscr();
    printf("Enter the Size: ");
    scanf("%d", &n); // take input from user

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

    getch();
    }

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

    ReplyDelete
  49. how to print this pattern through c language can any body help????
    *
    **
    ***
    ****
    *****

    ReplyDelete
  50. how to print this pattern through c language
    1
    22
    333
    4444
    55555

    ReplyDelete
  51. Hi i need a program coding for
    1
    2 4
    3 6 9
    4 8 12 16
    5 10 15 20 25

    Please help me anybody,,!!

    ReplyDelete
  52. how to print
    ______1
    _____121
    ____13431
    ___1446441
    plz help

    ReplyDelete
  53. Write a C program to display the following. (Hint: use 2 loops, 1 loop inside another loop) plzzz help
    **********
    **********
    **********
    **********
    **********
    **********
    **********
    **********
    **********
    **********

    ReplyDelete
  54. how to print....
    - - - a
    - - a b a
    - a b c b a
    a b c d c b a

    ReplyDelete
  55. how to print....
    1
    22
    123
    4444
    12345

    please how to print....

    ReplyDelete
  56. 1
    22
    333
    4444
    55555

    ------------------------------

    int num1;
    int num2;
    int Number;
    Number = ReadIntPr("Enter a number: ");
    for(num1=1; num1 <= Number; num1++)
    {
    for(num2=1; num2 <= num1; num2++)
    WriteString(num1);
    WriteString("\n");
    }

    ReplyDelete
  57. i need the program for 0
    1
    2 2
    3 3 3
    4 4 4 4
    5 5 5 5 5

    ReplyDelete
  58. 1111111
    1A1AAAA
    1AA1AAA
    1AAA1AA
    1AAAA1A
    1AAAAA1
    1AAAAAA

    ReplyDelete
  59. 1111111
    1A1AAAA
    1AA1AAA
    1AAA1AA
    1AAAA1A
    1AAAAA1
    1111111

    ReplyDelete
  60. creating pyramid of numbers is the basic lab c program used in many institutions. Thank you for sharing this program.
    regards:
    srinath reddy.
    admin of Programming Tutorials for Beginners

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

    ReplyDelete
  62. i need code for printing
    1
    4 5
    7 8 9

    ReplyDelete
  63. How to print any name vertically,using pointers? In C??? Plz give me the code I'm using arry and it's runs but with pointer it's not working. 😕

    ReplyDelete


If you face any Problem in viewing code such as Incomplete "For Loops" or "Incorrect greater than or smaller" than equal to signs then please collect from My Web Site CLICK HERE


More Useful Topics...

 

History Of C..

In the beginning was Charles Babbage and his Analytical Engine, a machine
he built in 1822 that could be programmed to carry out different computations.
Move forward more than 100 years, where the U.S. government in
1942 used concepts from Babbage’s engine to create the ENIAC, the first
modern computer.
Meanwhile, over at the AT&T Bell Labs, in 1972 Dennis Ritchie was working
with two languages: B (for Bell) and BCPL (Basic Combined Programming
Language). Inspired by Pascal, Mr. Ritchie developed the C programming
language.

My 1st Program...


#include
#include
void main ()
{
clrscr ();
printf ("\n\n\n\n");
printf ("\t\t\t*******Pankaj *******\n");
printf ("\t\t\t********************************\n");
printf ("\t\t\t\"Life is Good...\"\n");
printf ("\t\t\t********************************");
getch ();
}

Next Step...


#include
#include

void main ()
{
clrscr ();
printf ("\n\n\n\n\n\n\n\n");
printf ("\t\t\t --------------------------- \n\n");

printf ("\t\t\t | IGCT, Info Computers, INDIA | \n\n");
printf ("\t\t\t --------------------------- ");

getch ();

}

Hits!!!