Please note, this is a STATIC archive of website www.w3resource.com from 19 Jul 2022, cach3.com does not collect or store any user information, there is no "phishing" involved.
w3resource

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

C# Sharp For Loop: Exercise-58 with Solution

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

Pictorial Presentation:

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

Sample Solution:

C# Sharp Code:

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

Sample Output:

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

Flowchart:

Flowchart: display alphabet pattern like A with an asterisk

C# Sharp Code Editor:

Contribute your code and comments through Disqus.

Previous: Write a program in C# Sharp to print a string in reverse order.
Next: Write a C#Sharp program to display alphabet pattern like 'B' with an asterisk.

What is the difficulty level of this exercise?

Test your Programming skills with w3resource's quiz.