Question #36752
Write a calculate power of given number by user. in csharp
1
Expert's answer
2017-05-05T11:19:27-0400
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks;class PowerProg {          private static int Power (int a, int n)        {                      int res = 1;                      for (int i = 0; i < n; i++)           {                          res *= a;          }               return res;    }    static void Main ()   {            System.Console.Write ("Input a: ");           int a = int.Parse(System.Console.ReadLine ());            System.Console.Write ("Input n: ");           int n = int.Parse(System.Console.ReadLine());            System.Console.WriteLine("a^n = " + Power(a, n).ToString());            System.Console.ReadKey ();    } }

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!
LATEST TUTORIALS
APPROVED BY CLIENTS