8/01/2011

C# Star Pattern (9)

C# Star Pattern (9)
C# Star Pattern (9)


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

C# Star Pattern (8)

C# Star Pattern (8)
C# Star Pattern (8)


/* 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 = i; j < 5; j++)  
         {  
           Console.Write(" ");  
         }  
         for (k = 1; k < (i * 2); k++)  
         {  
           Console.Write("*");  
         }  
         Console.WriteLine();  
       }  
       for (i = 4; i >= 1; i--)  
       {  
         for (j = 5; j > i; j--)  
         {  
           Console.Write(" ");  
         }  
         for (k = 1; k < (i * 2); k++)  
         {  
           Console.Write("*");  
         }  
         Console.WriteLine();  
       }      
     }  
   }  
 }

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();  
       }      
     }  
   }  
 }

C# Star Pattern (6)

C# Star Pattern (6)
C# Star Pattern (6)


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

C# Star Pattern (5)

C# Star Pattern (5)
C# Star Pattern (5)


/* 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 = i; j < 5; j++)  
         {  
           Console.Write(" ");  
         }  
         for (k = 1; k < (i * 2); k++)  
         {  
           Console.Write("*");  
         }  
         Console.WriteLine();  
       }      
     }  
   }  
 }

C# Star Pattern (4)

C# Star Pattern (4)
C# Star Pattern (4)


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

C# Star Pattern (3)

C# Star Pattern (3)
C# Star Pattern (3)


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

C# Star Pattern (2)

C# Star Pattern (2)
C# Star Pattern (2)


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

C# Star Pattern (1)

C# Star Pattern (1)
C# Star Pattern (1)



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