0
How the syntax of a^b=c
for example, 2^2=4 and 3^3=27 also 2^4=16 how I suppose to code that? thanks in advance
1 Respuesta
+ 2
Usually, there is either case in any of programming languages:
1,
There is a static Math class or library
with operation methods you can use, like:
c = Math.Power(a, b)
2,
There is an operator for it, like:
c = a ^ b
If none of the above is given you are free to search on the net for "<lang name> power of number" or as the last solution, you can write a similar method as Math.Power yourself.
Exact cases of 5^2:
[C#]
double c = Math.Pow(a, b);
Console.WriteLine(Math.Pow(5, 2));
[Java]
double c = Math.pow(a, b);
System.out.println(Math.pow(5, 2);
[Python]
c = a ** b;
c = math.pow(a, b);
print(5 ** 2);
[C++]
#include <cmath>
cout << pow(5, 2);