0

Math.Pow method question in C#

Hi, Can someone just explain this output. Math.Pow(b,a)=10240000000000 Here is the code from another tutorial resource I am using. I wanted to know understand the output Math.Pow(b,a)=10240000000000 I understand the other output just stuck on the Math,Pow method example here. /* example 4 */ using System; namespace VariableDefinition { class Program { static void Main(string[] args) { int a = 10, b = 20, c0, c1; double c2, c3, c4, c5; c0 = b + a; /* b plus a */ c1 = b - a; /* b minus a */ c2 = b / a; /* b divided by a */ c3 = b * a; /* b times a */ c4 = b % a; /* b mod a */ c5 = Math.Pow(b, a); /* b raised to the a power */ /* note the use of the string concatenation operator; i.e. the + sign */ Console.WriteLine("b+a={0}, b-a={1}, b/a={2}, b*a={3}, b%a={4}, " + "Math.Pow(b,a)={5}", c0, c1, c2, c3, c4, c5); Console.ReadLine(); } } }

11th Nov 2019, 12:34 AM
Making A Change
Making A Change - avatar
2 Respuestas
+ 2
Actually, the comment under the statement already explained the purpose. Math.Pow(b, a) raises <b> to the power of <a>. It was as if you multiply 20 by itself 10 times. Math.Pow(10, 3); Means 10 * 10 * 10 => 1000
11th Nov 2019, 1:07 AM
Ipang
+ 1
Thanks I was not clear on how to calculate 20 to the 10th power. which is 1024000000000. I had to use a calculator to figure out
11th Nov 2019, 1:51 AM
Making A Change
Making A Change - avatar