If x and y are floats, or you don't mind the overhead, you can use the pow function.
If x and y and integers, then x^y is just x times itself y times. A for loop to multiply x by itself y times will work.
There may be a better way to do whatever it is you are trying to do. Can you explain what is in the array, and where it came from, and what you are trying to construct from the array?
It looks like you are trying to take an array of integers, like 1, 2, 6, and 3, and construct a number like one thousand, two hundred sixty three from it. Is that right?
It looks like you are trying to take an array of integers, like 1, 2, 6, and 3, and construct a number like one thousand, two hundred sixty three from it. Is that right?
It works fine. But I don't like the fact that it is a float. How could I calculate the POWER without using floats without using the For loop? (the loop seems too hard for such a simple thing)
To multiply repeatedly, you have to loop somewhere.
There's a common algorithm for converting (1,2,3,4) to (1234) where the loop through the digits is used to collect the multiplications as well:
number=0;
for (intIndex = 1; intIndex <= max_intIndex; intIndex++) {
number = number*10 + intArray[intIndex];
}