Answer to Question #327042 in C++ for chin

Question #327042

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

1
Expert's answer
2022-04-11T07:48:29-0400
#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;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS