Skip to content Skip to sidebar Skip to footer

Making Pyramid with C/C++

#include<stdio.h>
#include<conio.h>

void main()
{
   int i = 0, j , n ;
   clrscr();
   printf("How many rows in pyramid:");
   scanf("%d",&n);

   while(i<n)
   {
             j=0;
             while(j<=i)
             {
               gotoxy(30+j,10+i);
               printf("%d",j);
               j++;
             }
             j=0;
            while(j<=i)
             {
               gotoxy(30-j,10+i);
               printf("%d",j);
               j++;
             }
             i++;
             printf("\n");
   }

   getch();
}

Remarks
For making two sides pyramid we have used two while loops and another while loop for controlling rows. Here gotoxy () function takes the curser to the specified location.

2 comments for "Making Pyramid with C/C++"

  1. THank You. Hello, I visit and give your full support and please support me back. Thank you in advance.

    ReplyDelete

If you want to comment, We appreciate.
Please do not include a link, use the Link Exchange Facility