77 919
Assignments Done
Successfully Done
In August 2019

Answer to Question #36752 in C# for Payal Panjwani

Question #36752
Write a calculate power of given number by user. in csharp
Expert's answer
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!


No comments. Be first!

Leave a comment

Ask Your question

Privacy policy Terms and Conditions