Answer to Question #337708 in C++ for Arr 1.11111

Question #337708

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

1
Expert's answer
2022-05-05T14:02:26-0400
#include<iostream>
#include<cmath>

using namespace std;

int main()
{
	const int sz=5;
	int* arr = new int[sz];
	cout << "Please, enter 5 values: ";
	for (int i = 0; i < sz; i++)
	{
		cin >> arr[i];
	}
	cout << "Multiple lines containing the cubes of the 3 elements of the given array:\n";
	for (int i = 0; i < sz; i++)
	{
		if(i%2==0)
			cout <<pow(arr[i],3) << endl;
	}
}

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