+ 2

How to output a Christmas tree using asterix (*), we should allowed to input the levels as well?

eg of an ouput using 3 levels * * * * * * * * * * * * * * * * * * *

28th Nov 2016, 6:55 PM
Nikhilesh Tacouri
Nikhilesh Tacouri - avatar
2 Answers
16th Dec 2017, 11:02 AM
Qqqq
Qqqq - avatar
+ 1
something like levels = user input for (i=1; i<= levels;i++) for (j=0; j<= i; j++) output= " * " * (j+1); cout<< /* padding code*/ << output<< endl; this would be a c++ model. don't remember how to pad off the top of my head but that's the basic logic of it
28th Nov 2016, 7:42 PM
Alex Lange
Alex Lange - avatar