CSharp - Write program to Raise the Power

Requirements

You will write a program to calculate the nth power of the number x given the decimal x and the positive integer n on its input.

Hint

You can repeat the multiplication by x.

Demo

using System;
class Program/*from  w  w w . j a  va2s.  co m*/
{
    static void Main(string[] args)
    {
        // Inputs 
        Console.Write("Enter x (number to be raised): ");
        string inputX = Console.ReadLine();
        double x = Convert.ToDouble(inputX);

        Console.Write("Enter n (power): ");
        string inputN = Console.ReadLine();
        int n = Convert.ToInt32(inputN);

        // Calculating 
        double result = 1;
        for (int count = 0; count < n; count++)
        {
            result *= x;
        }

        // Output 
        Console.WriteLine("x^n=" + result.ToString());

    }
}

Result