C++ Star Pyramid

Good day again, now I give the simple program that will print out a STAR PYRAMID with 10 layer. Hope it will be a help for a beginner like me.

Im using DEV C++, here is the source code:


#include<iostream.h>
#include<conio.h>

main()
{
int j=10;

for (int i=1;i<=10;i++)
{
for (int k=1;k<=j;k++)
{
printf(" ");
}
for (int x=1;x<=i;x++)
{
printf("*");
printf(" ");

}
printf("\n");
j--;
}
getch();
}
So, how did you get this code?
Did you just copy it from somewhere else or did you figure it out yourself?
Don't you think there might be some value in figuring it out yourself? Or in letting others figure it out themselves?

It doesn't help people to just give solutions to elementary problems.
By the way, the above solution won't compile on modern C++ implementations
Not to mention there is nothing C++ about it other than that it tries to include the io stream library instead of C stdio library, which is actually what the program uses.
What more do you need. It wont compile on a C compiler, will it? This is what the person who grades it will be looking after lol

EDIT: @OP Since the forum has been very hard on you, I must say, your intentions may be noble - spread the wealth and stuff. But you should have provided insight on the problem, not the code. Like explanation how something like that should be engineered would have been better. Because this is not Internet Homework Database you know.
Last edited on
Topic archived. No new replies allowed.