Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 8. Math Power
- Create a method that calculates and returns the value of a number raised to a given power:
- Examples
- Input Output
- 2
- 8 256
- 3
- 4 81
- Hints
- 1. As usual, read the input
- 2. Create a method which will have two parameters - the number and the power, and will return a result of type double:
- 3. Print the result
- using System;
- namespace _08MathPower
- {
- class Program
- {
- static void Main(string[] args)
- {
- var number = int.Parse(Console.ReadLine());
- var power = int.Parse(Console.ReadLine());
- double raiseToPower = NewMethod(number, power);
- Console.WriteLine(raiseToPower);
- }
- private static double NewMethod(int number, int power)
- {
- double calculation = 0.0;// Вместо 0.0 , може 0d.
- calculation = Math.Pow(number, power);
- return calculation;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment