Write a function power ( a, b ), to calculate the value of a raised to b.


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApplication19
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("enter number with power is to be calculated");
            int a = Convert.ToInt16(Console.ReadLine());
            Console.WriteLine("enter power");
            int b = Convert.ToInt16(Console.ReadLine());
            Program p = new Program();
            double c=p.power(a, b);
            Console.WriteLine(a+ " rase to the power "+b+ "="+c);

        }

        private double power(int a, int b)
        {
            double power = Math.Pow(a, b);
            return power;

        }

    }
}

Comments