Name numbers, tia Purpose is tocthe following cubePresent function that returns
ID: 3908825 • Letter: N
Question
Name numbers, tia Purpose is tocthe following cubePresent function that returns a also passed the size of the array to allow for loop two such numbers (for example, 3 5. (9 points) Complete the code for bool result. Its purpose is to check whether its numbers, contains any two numbers where one argument, an integer array of number is the cube of another. It is processing. If the array has any following first and 27, since 27 is the cube of 3), the function return true; otherwise, it returns false. The algorithm for the program is to compare each number in the array to every other number in the array. If a number the square of another number found, return true. After all comparing is done and no matches have been found, return false. //function prototype bool cubePresent (int . int): //function definition bool cubePresent( numbers size) for (int i-o; iExplanation / Answer
bool cubePresent(int numbers[], int size) {
for(int i=0; i<size; i++) {
for(int j=0; j<size; j++) {
if(j != i) {
if(numbers[i] == numbers[j]*numbers[j]*numbers[j]) {
return true;
}
}
}
}
return false;
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.