Click here to Skip to main content
15,881,204 members
Please Sign up or sign in to vote.
1.00/5 (6 votes)
See more:
I am trying to print '*' in triangle shape like

     *
    * *
   * * *
  * * * *
 * * * * *
* * * * * *


like this pattern very urgent

How can I achieve this?
Posted
Updated 4-Aug-12 1:57am
v3

We do not do your homework: it is set for a reason. It is there so that you think about what you have been told, and try to understand it. It is also there so that your tutor can identify areas where you are weak, and focus more attention on remedial action.

Try it yourself, you may find it is not as difficult as you think!
 
Share this answer
 
Comments
Tarun Mangukiya 4-Aug-12 8:52am    
You are right. This is simple work. And we are not here to do his homework.
OriginalGriff 4-Aug-12 9:28am    
He will learn nothing if we do! :laugh:
Tarun Mangukiya 4-Aug-12 9:50am    
Right :)
You will have to play with a certain amount of spaces at the beginning of each line.

One loop should do it:

for 0 to number_of_rows_you_want - 1
{
  the amount of spaces needed have a direct relationship with the current row number.
  the amount of * to be written is the number of iteration (current row).  
  here you will need another loop to print the * and spaces.
}


Seems you are starting, 2 important things you must know:

1. here we don't like to make homework, but we like to help people so try it and come with a specific question and we'll help for sure.
2. and more important: typically the problems can be divided in small parts, do it ALWAYS and you'll succeed in most of them.

Good luck!
 
Share this answer
 
v2
Comments
Tarun Mangukiya 4-Aug-12 8:53am    
Good One.
Joan M 7-Aug-12 11:58am    
Thank you Tarun!
BillW33 7-Aug-12 11:28am    
Your solution does not deserve a 1, have a 5 :)
Joan M 7-Aug-12 11:59am    
Thank you CIDev!
TryThis
 
Share this answer
 
v3
Comments
Joan M 4-Aug-12 8:44am    
Giving the code won't help as kishorereddy516 is learning.

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