P9 To find the value of X power of N

    class Program
    {
        static void Main(string[] args)
        {
            int x, n, i = 1, sum = 1;
            Console.WriteLine("Enter the value of x and n : ");
            x = int.Parse(Console.ReadLine());
            n = int.Parse(Console.ReadLine());
            while (i <= n)
            {
                sum = sum * x;
                i++;
            }
            Console.WriteLine(x + " power of  " + n + " is " + sum);
            Console.ReadLine();
        }
    }

Output : 



No comments:

Post a Comment