Hi, I am trying by best to code this program which takes user input of ten different numbers and displays it's square and cube, from the below code I can display the square of input numbers but in cube i am having problem please help me solving this.

``````#include <cstdlib>
#include <iostream>
#include <iomanip>
#include <cmath>

using namespace std;
const int size = 10;
const int size1 = 10;
void square_array (int values [size]);
void cube_array (int values [size1]);
int main(int argc, char *argv[])
{
const int size = 10;
const int size1 = 10;
int values [size];
int i [size];
int a [size1];
square_array (values);
cube_array (values);

cout << "\n\n";
system("PAUSE");
return EXIT_SUCCESS;
}
{
int index;
cout << "Enter 10 numbers:\n";
for (index = 0; index < size; index++)
cin >> values [index];
}
void square_array (int values [size])
{

int index;
cout << "\nThe square of your input numbers are:\n";
for (index = 0; index < size; index++)
{
values [index] = values [index] * values [index];
cout << "\n\n";
cout << "Square is ---> " << values [index];
}
}
void cube_array ( int values [size1])
{
int index;
cout << "\n\nThe cube root of the numbers are:\n";
for (index = 0; index < size1; index++)
{
values [index] = values [index] * values [index];
cout << "\n\n";
cout << values [index];
}

}``````

]

## All 3 Replies

1> use code tag

2> in function square_array() and cube_array() u are modifying the original array loosing the original values.

Good eye, dkalita.

In other words, OP, you need to either only display the values (save to an int and output that int) or, if you want to keep all the squared and cubed values, you'll need to store them in square_array and cube_array.

``````for(int i = 0; i < Size; i++){