Advertisement
minnera

#30daysofcode #day17

Oct 20th, 2017
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.27 KB | None | 0 0
  1. //https://www.hackerrank.com/challenges/30-more-exceptions/problem
  2.  
  3. //Write your code here
  4.  
  5. class Calculator{
  6.     public int power(int a, int b){
  7.         if(a < 0 || b < 0){
  8.             throw new Exception("n and p should be non-negative");
  9.         }
  10.         return (int)Math.Pow(a, b);
  11.     }
  12. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement