Number Pattern Program in C#

Advertisements

Prev Tutorial Next Tutorial

Print Number Pattern Program in C#

In C# this code is very simple to write just follow same concept like C and C++ programming only you need to change syntax.

print number pattern in c#

Print Number Pattern Program in C#

using System;  

public class NumberPattern  
 {  
  public static void Main()
  {
  int no = 5;
   for (int i = 1; i <= 5; i++)
  {
   for (int j = 1; j <= i; j++)
  {
  Console.Write(i);
  }
  Console.WriteLine();
  }
  Console.ReadKey();  
 }
}

Output

1
22
333
4444
55555

Print Number Pattern Program in C#

using System;  

public class NumberPattern  
 {  
 public static void Main(string[] args)
 {
  int i, j, rows, k = 1;
  Console.Write("Enter number of rows: ");
  rows = Convert.ToInt32(Console.ReadLine());
  for (i = 1; i <= rows; i++)
   {
   for (j = 1; j <= i; j++)
   Console.Write("{0} ", k++);
   Console.Write("\n");
  }  
 }
}

Output

Enter number of rows: 4
1
2 3
4 5 6
7 8 9 10

Print Number Pattern Program in C#

using System;  

public class NumberPattern  
 {  
  public static void Main(string[] args)  
   {  
   int  i,j,k,l,n;           
   Console.Write("Enter the Range: ");    
    n= int.Parse(Console.ReadLine());     
    for(i=1; i<=n; i++)      
    {          
     for(j=1; j<=n-i; j++)      
     {      
     Console.Write(" ");      
     }      
     for(k=1;k<=i;k++)      
     {      
     Console.Write(k);      
     }      
     for(l=i-1;l>=1;l--)      
     {      
     Console.Write(l);      
     }      
     Console.Write("\n");      
     }       
  }  
 } 

Output

Enter the Range: 4
      1
    121
  12321
1234321

Output

Enter the Range: 5
        1
      121
    12321
  1234321
123454321  

Prev Tutorial Next Tutorial

Google Advertisment

Buy This Ad Space @$20 per Month, Ad Size 600X200 Contact on: hitesh.xc@gmail.com or 9999595223

Magenet is best Adsense Alternative here we earn $2 for single link, Here we get links ads. Magenet

For Projects 9999595223

Google Advertisements


Buy Websites 9999595223

Buy College Projects with Documentation Contact on whatsapp 9999595223. Contact on: hitesh.xc@gmail.com or 9999595223 Try this Keyword C++ Programs

Advertisements