0

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

2
Contributors
2
Replies
3
Views
9 Years
Discussion Span
Last Post by jeenujoy
0
//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();
//;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

Edited by happygeek: fixed formatting

0
//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();
//;;;;;;;;;;;;;;;;;;;;;

Edited by happygeek: fixed formatting

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.