Q:

Write a C# Sharp program to display alphabet pattern like Q with an asterisk

0

Write a C# Sharp program to display alphabet pattern like Q with an asterisk

Sample Output:

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

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

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

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now