Cara membuat program sederhana print asterisk(bintang) c# Asp.Net Part7

Ikuti Code dibawah ini :

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace part7
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.Write("Input the number of an asterisk =");
            int n = int.Parse(Console.ReadLine());
            for (int i = 1; i <= n; i++)
            {
                for (int j = 1; j <= n; j++)
                {
                    if (i == j || i + j == n+1)
                    {
                        Console.Write("9");
                    }
                    else 
                    {
                        Console.Write("*");
                    }
                }
                Console.WriteLine();
            }
            Console.ReadLine();
        }
    }
}

  • Output

Previous
Next Post »