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!
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.
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.
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 =\
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