Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
AJ-Tuhin committed Mar 28, 2018
1 parent 6b87f18 commit 1b01f99
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions 30_Days-of_Code_Challenges/Day17MoreExceptions/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Day17MoreExceptions
{
class Program
{
static void Main(string[] args)
{
Calculator c = new Calculator();
Console.WriteLine(c.power(3, 5));
Console.WriteLine(Math.Pow(3, 5 ));
Console.ReadKey();
}
}
class Calculator
{
public int power(int n, int p)
{
int result = 1;
if (n < 0 || p < 0)
{
throw new Exception("n and p should be non-negative");
}
else
{
for (int i = 1; i <= p; i++)
{
result *= n;
}
}

return result;
}
}
}

0 comments on commit 1b01f99

Please sign in to comment.