write a programme to enter a number bteween 1-9 and shows like, if entered number is 5
then
it shows like
1
2 1
3 2 1
4 3 2 1
5 4 3 2 1
and also
like this
1
1 2
1 2 3
1 2 3 4
1 2 3 4 5
write a programme to enter a number bteween 1-9 and shows like, if entered number is 5
then
it shows like
1
2 1
3 2 1
4 3 2 1
5 4 3 2 1
and also
like this
1
1 2
1 2 3
1 2 3 4
1 2 3 4 5
//For first pgm this s the soln....
Console.Write("Enter no b/w 1-9:");
int n=Convert.ToInt32(Console.ReadLine());
for (int i = 1; i <= n; i++)
{
Console.Write(i);
int j = i;
while (j != 1)
{
j--;
Console.Write(j);
}
if (j == 1)
{
Console.WriteLine();
}
}
Console.ReadKey();
//;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
//for second one...
Console.Write("Enter no b/w 1-9:");
int n = Convert.ToInt32(Console.ReadLine());
for (int i = 1; i <= n; i++)
{
int j = 1;
Console.Write(j);
while (j != i)
{
j++;
Console.Write(j);
}
if (j == i)
{
Console.WriteLine();
}
}
Console.ReadKey();
//;;;;;;;;;;;;;;;;;;;;;
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.