1 an array containing 5 integer elements is already provided for you in the code editor below
2 print out the cube of the 1st, 3rd and 5th element of the given array
#include <iostream>
using namespace std;
int main() {
int array[5] = {1, 3, 4, 5, 8};
int x;
x = array[0];
cout << "Cube of 1st element: " << x*x*x << endl;
x = array[2];
cout << "Cube of 3rd element: " << x*x*x << endl;
x = array[4];
cout << "Cube of 5th element: " << x*x*x << endl;
return 0;
}
Comments
Leave a comment