w3resource
C# Sharp Programming Exercises

C# Sharp Exercises: Display alphabet pattern like I with an asterisk

C# Sharp For Loop: Exercise-66 with Solution

Write a C#Sharp program to display alphabet pattern like 'I' with an asterisk.

Pictorial Presentation:

C# Sharp Exercises: Display alphabet pattern like I with an asterisk

Sample Solution:

C# Sharp Code:

using System;  
public class Exercise66
{  
    public static void Main()
        {
    int row,column; 
   
    Console.Write("\n\n");
    Console.Write("Display the pattern like 'I' with an asterisk:\n");
    Console.Write("---------------------------------------------");
    Console.Write("\n\n");   
 
   for(row=0;row<=6;row++)
        {
         for (column=0; column<=6; column++)
            {
            if (column == 3 || (row == 0 && column > 0 && column < 6) || (row == 6 && column > 0 && column < 6))
              Console.Write("*");
             else
              Console.Write(" ");
            }
            Console.Write("\n");
        }
	Console.Write("\n");
   }
}

Sample Output:

Display the pattern like 'I' with an asterisk:                                                              
---------------------------------------------                                                               
 *****                                                                                                      
   *                                                                                                        
   *                                                                                                        
   *                                                                                                        
   *                                                                                                        
   *                                                                                                        
 *****

Flowchart:

Flowchart : Display the pattern like 'I' with an asterisk

C# Sharp Code Editor:

Contribute your code and comments through Disqus.

Previous: Write a C#Sharp program to display alphabet pattern like 'H' with an asterisk.
Next: Write a C#Sharp program to display alphabet pattern like 'J' with an asterisk.

What is the difficulty level of this exercise?



New Content: Composer: Dependency manager for PHP, R Programming