Wap to input 10 numbers in an array and print the array

Status
Not open for further replies.

hdeezie80

Honorable
Jul 18, 2012
205
0
10,710
In c++?

void numInput(int array, int index);
{
for ( i = 0; i < index; i++)
{
int temp = 0;
cout << "Enter number for index " << i << ": ";
cin >> temp;
array = temp;
}
}

If its just copying an array thats even easier

void copyArray(int array, int array2, index)
{
for (i = 0 ; i < index; i++)
array = array2;
}

you have to declare an array first like:

array[10] = 0;
numInput(array, 10);
for (i = 0; i < 10; i ++)
cout << array;


if its python

def numInput (max)
l = []
for i in range (0, max, 1) :
temp = raw_input("Enter number for index: ")
l.append(temp)
return l

list = numInput(10)
print list

pretty much the same for java, javascript, etc.

this is pretty easy stuff though, if your struggling with this you should definitely study or read because your going to have a really tough time with classes, exceptions, lambda expressions, etc later on
 
Status
Not open for further replies.