8/01/2011

C# Star Pattern (7)

C# Star Pattern (7)
C# Star Pattern (7)


/* C# program to print the following pattern   
 **********  
 ****  ****  
 ***    ***  
 **      **  
 *        *  
 **      **  
 ***    ***  
 ****  ****  
 **********   */  
 namespace Patterns   
 {  
   class Program  
   {  
     static void Main(string[] args)  
     {  
       int i, j, k;  
       for (i = 1; i <= 5; i++)  
       {  
         for (j = 1; j <= 6 - i; j++)  
         {  
           Console.Write("*");  
         }  
         for (k = 1; k < i; k++)  
         {  
           Console.Write(" ");  
         }  
         for (j = 1; j <= 6 - i; j++)  
         {  
           Console.Write("*");  
         }  
         Console.Write("\n");  
       }  
       for (i = 2; i <= 5; i++)  
       {  
         for (j = 1; j <= i; j++)  
         {  
           Console.Write("*");  
         }  
         for (k = 1; k <= 5 - i; k++)  
         {  
           Console.Write(" ");  
         }  
         for (j = 1; j <= i; j++)  
         {  
           Console.Write("*");  
         }  
         Console.WriteLine();  
       }      
     }  
   }  
 }

No comments:

Post a Comment