I've just started programming and am having a hard time determining how to complete this exercise:
Use a for loop to create the following shapes:
* *********
***
********
***** *******
******* ******
********* *****
******* ****
***** ***
***
**
* *
for (int i = 0; i < 10;i++)
{
Console.Write("*");
if(i == i)
{
Console.WriteLine("*");
}
}
Console.Read();
Can anyone show me how to accomplish this?
Thanks in advance, C# is pretty cool.
Chris
ChristopherPosted Jun 3, 2010, 1:07 PM
Sorry for the delay - I just wanted to say thanks for your reply. I never would have figured this out, and now I can at least study the solution. Thanks again.
Kirtan PatelPosted May 30, 2010, 2:48 PM
static void Main(string[] args)
{
int n;
Console.WriteLine("How many stars ?");
n = Convert.ToInt32(Console.ReadLine());
for (int i = 0; i < n; i++)
{
for (int j =i;j<=n; j++)
{
Console.Write(" ");
}
for (int k = 0; k <= i; k++)
{
Console.Write("* ");
}
Console.Write("\n");
}
for (int i = 0; i<=n; i++)
{
for (int j = 0; j <=i; j++)
{
Console.Write(" ");
}
for (int k = n; k>= i; k--)
{
Console.Write("* ");
}
Console.Write("\n");
}
Console.ReadKey();
}
/* Out put */
*
***
*****
*******
*********
*******
*****
***
*
Another Program you can solve your self from this example if you dont do this you will not learn the logic ..