Write a java program for calculating a^b input by the user? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Write a java program for calculating a^b input by the user?

29th Jan 2017, 12:55 PM
Divyanshu Kumar
Divyanshu Kumar - avatar
3 Answers
+ 2
Math.pow(a,b);
29th Jan 2017, 12:57 PM
Leon
Leon - avatar
+ 2
prod=1; for(int x=0; x<b; x++) prod*=a; But it doesn't like floats
29th Jan 2017, 12:59 PM
Leon
Leon - avatar
0
can't. we use loop in this?
29th Jan 2017, 12:58 PM
Divyanshu Kumar
Divyanshu Kumar - avatar