2/02/2012

C# Number Pattern (18)

C# Number Pattern (18)
C# Number Pattern (18)

 /* C# program to print the following pattern   
 55555  
 45555  
 34555  
 23455  
 12345  */  
 namespace Patterns //18  
 {  
   class Program  
   {  
     static void Main(string[] args)  
     {  
       int i, j, k;  
       for (i = 5; i >= 1; i--)  
       {  
         k = i;  
         for (j = 1; j <= 5; j++)  
         {  
           if (k <= 5)  
           {  
             Console.Write(k);  
           }  
           else  
           {  
             Console.Write("5");  
           }  
           k++;  
         }  
         Console.WriteLine();  
       }        
     }  
   }  
 }  

No comments:

Post a Comment