multiplying the variables into powers | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

multiplying the variables into powers

hi, tried to make one variable into power of one integer, ie., for example int a = 10 and i tried to get an answer int b = a^2, the answer i'm getting is 12. which is wrong right.. pls guide how to make use of power. Thanks - Martin

13th Oct 2020, 9:52 AM
Martin Joshwa
3 Answers
+ 6
To calculate power of numbers in python, you don't need to import math. Just use: print(pow(2,3)) The result will be 8 - > 2*2*2
13th Oct 2020, 1:43 PM
Lothar
Lothar - avatar
+ 3
Martin Joshwa can you mention the programming language? Because it make easy for the answerer to answer your question.... because this type of powering the number concept is different from one language to another...
13th Oct 2020, 10:04 AM
Yogeshwaran P
Yogeshwaran P - avatar
+ 2
^ is bitwise xor operator..
13th Oct 2020, 11:44 AM
Jayakrishna 🇮🇳