Confused and need help

Write a program that creates an double array that is 1000 elements large. Set the value of the first element to be equal to 100. Set the value of each element after the first to be equal to 0.99 times the value before it.

Then, the program will ask the user which element they would like the program to print out. After the user types in the value of some integer between 0 and 999 inclusive, the program will print out that value from the array.

This is my assignment for my CISP class ,and I have become completely lost. I have tried googling things and searching through my book about arrays and just cant figure out this code. Any tips would be appreciated Thank-you in advance! Also the for statements is something i found on google.


#include <iostream>
#include <string>


int main()
{

int myarray[1000];

int i = 100;

while (i < 1000)
{
myarray[100] = myarray[1000];
i = myarray[100] + .99;
}

for (i = 100; i < 1000; i++)
myarray[i] = 100;
for (i = 100; i < 1000; i++)
std::cout << myarray[i] << '\n';



return 0;
}
Ok, let's help you get back on track. First off if the prompt you have given does not need string so that can be removed. Next it wants an array of 1000 doubles so int myarray[1000]; should be double myarray[1000];. Next, it asks for us to set the first value of the array to be 100 so let's do myarray[0] = 100;. Next, it asks us to make every value equal to 0.99 times the value before it. So we will need a loop that goes through the entire array and sets a value equal to the value before it times .99. Try writing the line of code to do that(sets a value equal to the value before it times .99.)
Last edited on
Alright thank-you for the help! If I have any more questions I will post!
Topic archived. No new replies allowed.