how to create a arry that stores the first 100 multiples of a user-supplied integer, prints the values forward and backwarf rom storage (in an array); prints any values that are multiples of a second user-supplied integer or a message indication that there are no multiples of tha number if that is so

To get ye' started, here is how to create an array and store the first 100 multiples of a number into that array

(assuming that no number in the array exceeds the bounds of the datatype size int )

int array[100] ;

cout << "Enter a number: " ;
cin >> array[0] ;

for (int i=0; i<99; i++)

    array[i+1] *= array[i] ;

at this point, you have a populated array of integers. how you want to test the array.. and display it is up to you.

That only generates 99 numbers. You should have "i<100".

Nope i think it is alright since he has initially assigned the first element of the array with the value from cin >> array[0]; and the remainig 1 to 99 elemets get assigned values from the statement

for (int i=0; i<99; i++)
    array[i+1] *= array[i] ;

Hope i am right.

> array[i+1] *= array[i] ; Since this is just short for array[i+1] = array[i+1] * array[i] ; All the calculations involve undefined values because i+1 element is read before being written (in the absense of any other initialisation).

This article has been dead for over six months. Start a new discussion instead.