need to make an array keep calculating until it reaches number 1

i dont know how to make an array so that you can input a number.. it will do the calculations and keep putting these numbers into the array until the number is equal to 1 then output the numbers in the array.... this is what i have so far im just lost, my book is not very explanatory


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#include <cstdlib>
#include <iostream>
#include <cmath>


using namespace std;

int main(int argc, char *argv[])
{
    int x;
    char again;
    //programmer info
    cout << "Programmer Name: Brandon Holtz\n";
    cout << "Program 3 Description: Analyzes sequences, etc..\n";
    cout << "CS150 Spring 2011, CRN 26670\n\n";
    //prmpts the user for an integer
    do { cout << "Enter a nonnegative integer please ";
    cin >> x;
    //makes calculations 
    if (x % 2== 0)
    cout << x / 2 ;
   
    else 
    cout << (x * 3) +1;
    
    cout << "Would you like to try again? (Enter Y or N) ";
    cin >> again;
} 
while (again == 'Y' || again == 'y');  //loops if the user wants it to

return 0;
    

    
    system("PAUSE");
    return EXIT_SUCCESS;
}
Well, your code is nothing like your description, and guessing from your intro, you probably need a vector to store your results: http://www.cplusplus.com/reference/stl/vector/
Topic archived. No new replies allowed.