Search This Blog


Friday, December 9, 2011

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.
Posted by: Admin
Easy Learn Computer, Updated at: 9:24 PM

2 komentar:

Edy Sant said...

shotmix error, smile here

GLace TIng said...

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

Post a Comment

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