pyramid w/ imputted base length

hi guys, i need help writing a code to produce a pyramid of *'s. the user needs to imput the base lenght and the pyramid should then form with the base number of *'s being the number imputted. the product should look like this;

Enter base #; 9



....*
...***
..*****
.*******
*********
(periods are to show what kind of pyramid i need to form)

the code should only use
#inclue<iostream>
using namespace std
&
int main()

someone please help with the code for this, thanks!
Where do all these "pyramid of *" questions keep coming from? Is there some class somewhere that repeats the same question every fortnight?
closed account (1yR4jE8b)
It's a very common first year comp-sci assignment question.
From what I can tell, the number of spaces for the first asterisk can be determined with the formula (n-1)/2 where n is the base #. Then, every subsequent line has 1 less space before the first asterisk.
closed account (3hM2Nwbp)
I would think that campuses would have a course before C++ in dealing with pseudo-code. The campus that I attended had "Object Oriented Analysis & Problem Solving" which dealt with the simple control structures.

Neverknownig - work out the pseudo-code before trying to write it in C++ and post what you come up with.
so can anyone help me with the code for this or no?
No one here will do your homework for you. The best we'll do is give you helpful hints.

Use the formula numspaces=(n-1)/2 to determine the number of spaces before the first asterisk, use cout<<"this is a string" to output stuff to the console, and use a for loop to create the pyramid. I can't really say much more without doing it for you =\
yeah, this is for my dad. not homework. thanks though.
neverknownig wrote:
this is for my dad. not homework.

I have a hard time believing that.
How about some pseudo code?

1
2
3
4
5
6
7
8
9
10
var base
var space
var line
input base
space=(base-1)/2
while line is less than or equal to base
	output ' ' space times
	output '*' line times
	space=space-1
	line=line+1
Topic archived. No new replies allowed.