How i write a^b | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

How i write a^b

23rd Nov 2018, 1:09 PM
Andrei
Andrei - avatar
5 Answers
+ 7
Using power function :) pow(a,b) where a is base and b is its power
23rd Nov 2018, 1:11 PM
Abhijeet Srivastava
Abhijeet Srivastava - avatar
+ 6
It depends, the ^ symbol is the bitwise XOR operator, if you want to XOR a and b then you simply do as you just did. But if you mean to raise a to the power of b, then, as suggested earlier by Abhijeet Srivastava, use pow() function; and don't forget to include <cmath> header : )
23rd Nov 2018, 2:05 PM
Ipang
+ 5
The power of a number is the result of the multiplication of this number by itself a certain number of times according to the exponent. For example : 4^4 = 4 × 4 × 4 × 4 = 256 10^-5 = 10 ÷ 10 ÷ 10 ÷ 10 ÷ 10 = 0.001
23rd Nov 2018, 5:51 PM
program
program - avatar
+ 2
pow(a,b) a is a number and b is it's power.
24th Nov 2018, 11:43 PM
Roopesh
Roopesh - avatar
+ 1
thx
23rd Nov 2018, 2:17 PM
Andrei
Andrei - avatar