/******************************************************/ /* Introduction to Programming */ /* By Dr. ANTF */ /* www.antf.net */ /* Copyright 2015 */ /* */ /* C# 333 - Test 1: Problem 4 (a) */ /******************************************************/ using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace DOS { class Program { static void Main(string[] args) { int n; Console.Write("Please enter an Odd number: "); n = int.Parse(Console.ReadLine()); //check for even while (n % 2 == 0) { Console.Write("You entered an even number, please enter an Odd number: "); n = int.Parse(Console.ReadLine()); } Console.Write("\n"); //first triangle for (int i = 0; i < n / 2 + 1; i++) { for (int j = 0; j < i + 1; j++) Console.Write("*"); Console.Write("\n"); } //second triangle for (int i = 0; i < n / 2; i++) { for (int j = 0; j < n / 2 -i; j++) Console.Write("*"); Console.Write("\n"); } Console.ReadKey(); } } }