/******************************************************/ /* Introduction to Programming */ /* By Dr. ANTF */ /* www.antf.net */ /* Copyright 2015 */ /* */ /* C# 406 - Problem 5: Power Function */ /******************************************************/ using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace DOS { class Program { static int Power(int _base, int _exponent) { int mul = 1; for(int i=0; i<_exponent; i++) { mul = mul * _base; } return mul; } static void Main(string[] args) { int x, y; Console.Write("Please enter the base: "); x = int.Parse(Console.ReadLine()); Console.Write("Please enter the exponent: "); y = int.Parse(Console.ReadLine()); Console.WriteLine("\n\n{0} to the power {1} is {2}", x, y, Power(x, y)); Console.ReadKey(); } } }