Click here to Skip to main content
15,890,527 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
* **
***
****

how do u print this using a single for loop for reducing the complexity and for optimizing the program. Its fine wid two for loops.
Posted
Updated 21-Dec-11 4:31am
v2
Comments
TorstenH. 21-Dec-11 10:32am    
added homework tag.
What have you got? we'll not post solutions.
LanFanNinja 21-Dec-11 10:41am    
Not sure I see another way using only a single for loop!?
Chris Meech 21-Dec-11 10:51am    
Why do you need a for loop? Just print the string "*\n**\n***\n****\n".
thatraja 21-Dec-11 12:08pm    
Better, 5!

1 solution

Do you understand the concept of counting from 1 to N and then stopping? Then try and convert that into the few steps of code to solve your problem.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900