An array containing 5 integer elements is already provided for you in the code editor below.
Print out the cube of the 1st, 3rd, and 5th element of the given array.
Output
Multiple lines containing the cubes of the 3 elements of the given array.
-8
1
27
#include <iostream>
using namespace std;
int main() {
int arr[5] ={-2, 6, 1, 3, 3};
for(int i = 0; i <5; i+=2) {
cout<< arr[i]*arr[i] * arr[i]<< endl;
}
return 0;
}
Comments
Leave a comment