+ 5
How to initialise the power of number without using .math package in java ...??
8 odpowiedzi
+ 30
Math.pow(2,3), here 2 is base and 3 is power.
You don't need to import any package.
Did you mean without using any library function?
Hint:
To calculate 2^3 using loop, you need to multiply 2 with itself 3 times.
2^3 = 2*2*2
+ 27
You can't initialize using ^ operator. It has different meaning. There's no such operator for power. You'll have to use library function Math.pow()
+ 2
i know this method but i want to solve without using this function ... if you know the so tell me
+ 2
i want to initialise 🙄
+ 2
int i=10;
int j=1;
int k=i^j;
👆👆
i want to initialise like this but I don't know perfect coding .... anybody know the answer please suggest me...
+ 1
Are you talking about finding the power without using any functions ?
0
you have to use math.pow
it's return type is double .so u have to do type casting
INT k=Integer.parseInt(math.pow(i,j))
or
INT k= (int)math.pow(i,j)