jloga4
1/2/2017 - 9:09 PM

How to calculate the power exponent value.

How to calculate the power exponent value.

double m, n;
		
Console.WriteLine("Enter the Number: ");
m = double.Parse(Console.ReadLine());

Console.WriteLine("Enter the Exponent: ");
n = double.Parse(Console.ReadLine());
double value1 = Math.Pow(m, n);

Console.WriteLine("Result: {0}", value1);
Console.Write("n = ");
int n = int.Parse( Console.ReadLine());

Console.Write("m = ");
int m = int.Parse( Console.ReadLine());

decimal result = 1;

for (int i = 0; i < m; i++)
{
  result *= n;
}
Console.WriteLine( "n^m = " + result);