Help with C++

My goal for this program is to have it allow a user to enter any amount of numbers up to 12 until a sentinel value is entered and display them in reverse order.
What I have is not correct and is returning errors. Can anyone tell me what I am doing wrong?

<code>
// Programmer: Curtis Moffitt
// This program accepts up to 12 numbers and displays them in reverse order of entry.


#include <iostream>
#include <string>
using namespace std;

int main()
{
// Declare variables
int size;
int number[size];
int count;
int sentinel = -1;
int value;


count = 0;
while (count != 12 || value != sentinel);
{
cout << "Enter a number (-1 to stop). " << endl;
cin >> value;
if (value == sentinel)
size = count;
if (value != sentinel)
{
number[count] = value;
size = count;
}
count++;
}

cout << "The numbers reversed are... " << endl;


count = size - 1;
while (count >= 0)
{
cout << number[count] << endl;
count--;
}

cout << endl;

system("pause");

return 0;
}
</code>

What I have is not correct and is returning errors.

Can you be more specific? Are you getting compilation errors? Run-time errors? Unexpected behaviour?

The more you tell us about the problem you're seeing, the easier it is for us to help you.

EDIT: As you should have already noticed, you got the code tags wrong. They should be square brackets, not angular ones.
Last edited on
Topic archived. No new replies allowed.