Web Hosting Talk







View Full Version : C++ Pyramid Help


CresHost
11-16-2006, 08:04 AM
Hello,

I need to make a pyramid which show:
X
XX
XXX
XXXX

upto 20 lines

I have made a program but it shows:
X
XX
XXX
XXXX
XXXXX

I have used two for loops , I know I need to use 3 for loops , one for the spaces but i am not understanding how to do that .

This is my current code :

#include<iostream.h>
#include<conio.h>
void main(void)
{
for ( int i=1; i<=20; i++ )
{

for ( int k=1; k<=i; k++ )


{
cout<<"X";
}


cout<<endl;
}
getch();
}


Any help?

Thanks

Slidey
11-16-2006, 06:44 PM
wasnt this done already this week?