Question: Program to print the following pattern.
5
4 5
3 4 5
2 3 4 5
1 2 3 4 5
Code Snippet:
- using System;
- public class pattern
- {
- public static void Main()
- {
- int row, col, n;
- Console.Write("Enter th eno. of row: ");
- n=Convert.ToInt32(Console.ReadLine());
- int temp=n;
- for(row=1; row<=n; row++)
- {
- for(col = temp; col<=n; col++)
- Console.Write("{0} ",col);
- temp--;
- Console.WriteLine();
- }
- Console.ReadLine();
- }
- }
Fig: Screenshot of output |