In this blog i am going to explain 2 to 3 important star pattern in c#, which the interviewer are commonly asking during interview.
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace variables
- {
- class demo
- {
- static void Main(string[] args)
- {
- Console.WriteLine("enter value of n");
- int n = Convert.ToInt32(Console.ReadLine());
- for (int i = n; i >= 1; i--)
-
- for (int j = 1; j <= i; j++)
- {
- Console.Write(j);
- }
- }
- Console.ReadLine();
- }
- }
- }
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace variables
- {
- class demo
- {
- static void Main(string[] args)
- {
- Console.WriteLine("enter value of n");
- int n = Convert.ToInt32(Console.ReadLine());
- for (int i = n; i >= 1; i--)
- {
- Console.WriteLine(" ");
- for (int j = 1; j <= i; j++)
- {
- Console.Write(" ");
- }
- for (int q = i; q <= n; q++)
- {
- Console.Write(" * ");
- }
- }
- Console.ReadLine();
- }
- }
- }