Click here to Skip to main content
15,921,793 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
* ***
*****
*******
*********
***********
**********
*******
****
**
*

How do I print the above using C#? Can you please show me the source code also?
Posted
Updated 6-Feb-10 4:05am
v2

Console application

+

System.Console.Out.WriteLine

+

some for loops

+

some variables

+

System.Threading.Thread.Sleep

=

asterisks program.

Also, get a book and learn some C# so you don't have to ask questions as basic as this one.
 
Share this answer
 
This is a question used in programming classes, try to do your own homework.
 
Share this answer
 
To make this really interesting - you should do it using a recursive algorithm. That way you should get a good mark!
 
Share this answer
 
use for loop from 1 to n and from n-1 to 1
 
Share this answer
 
I will give you more hint.
C#
Console.WriteLine("Enter n:");
int n = Convert.ToInt32(Console.ReadLine());
for (int i = 1; i <= n; i++)
{
     for (int j = 1; j <= 2 * i - 1; j++)
     {
           Console.Write("*");
     }
     Console.WriteLine();
}
Console.ReadLine();

TODOS: 1) Similarly go downwards
2) Add line of code to put correct spaces

Consider answers from all the responders and put some effort. You will surely be able to do it. :thumbsup:
 
Share this answer
 
v2

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