Printing Stars, blank spaces,
numbers for making diagrams
Q1).........
Console.WriteLine("Enter a number to print tringle");
int i = int.Parse(Console.ReadLine());
for (int row = 1; row <= i; row++)
{
for (int col = 1; col <= row; col++)
{
Console.Write(row);
}
Console.WriteLine();
}
Console.ReadLine();
Q2)........
Console.WriteLine("Enter a number to print tringle");
int i = int.Parse(Console.ReadLine());
for (int row = 1; row <= i; row++)
{
for (int col = 1; col <= row; col++)
{
Console.Write("$");
}
Console.WriteLine();
}
Console.ReadLine();
Q3)........
Console.WriteLine("Enter a number to print
tringle");
int i = int.Parse(Console.ReadLine());
for (int row = 1; row <= i; row++)
{
for (int col = 1; col <= row; col++)
{
Console.Write(col);
}
Console.WriteLine();
}
Console.ReadLine();
Q4)...........
Console.WriteLine("Enter a number");
int i = int.Parse(Console.ReadLine());
for (int row = 1; row <= i; row++)
{
for (int sps = i - 1; sps >= row; sps--)
{
Console.Write(" ");
}
for (int col = 1; col <= row; col++)
{
Console.Write(row + "
");
}
Console.WriteLine();
}
Console.ReadLine();
Q5)...........
for (int row = 1; row <= 7; row = row + 2)
{
for (int sps = 5; sps >= row; sps = sps -
2)
{
Console.Write(" ");
}
for (int col = 1; col <= row; col++)
{
Console.Write("*");
}
Console.WriteLine();
}
Console.ReadLine();
Q6)...........
Console.WriteLine("Enter a number to print
tringle");
int i = int.Parse(Console.ReadLine());
for (int row = i; row >= 1; row--)
{
for (int sps = i; sps != row; sps--)
{
Console.Write(" ");
}
for (int col = row; col >= 1; col--)
{
Console.Write(col);
}
Console.WriteLine();
}
Console.ReadLine();
Q7)
Console.WriteLine("Enter a number to print
tringle");
int i = int.Parse(Console.ReadLine());
for (int row = i; row >= 1; row--)
{
for (int sps = i; sps != row; sps--)
{
Console.Write(" ");
}
for (int col = row; col >= 1; col--)
{
Console.Write(row);
}
Console.WriteLine();
}
Console.ReadLine();
Q8)
Console.WriteLine("Enter a number to print
tringle");
int i = int.Parse(Console.ReadLine());
for (int row = i; row >= 1; row--)
{
for (int sps = i; sps != row; sps--)
{
Console.Write(" ");
}
for (int col = i; col >= 1; col--)
{
Console.Write("*");
}
Console.WriteLine();
}
Console.ReadLine();
No comments:
Post a Comment