int table [10];
      for (int x = 0; x < 20, x++)
      {
          cout << “Enter the next value: “;
          cin >> table [x]
       }

is it at the cin line? and im not sure if a semicolon is needed.
thanks:icon_cheesygrin:

Recommended Answers

All 2 Replies

>im not sure if a semicolon is needed.
The basic guideline is that the semicolon is a statement terminator, so unless you're working with a compound statement (where braces surround zero or more statements), you need to finish with a semicolon. That's why you don't need a semicolon after this if statement:

if ( [I]<condition>[/I] ) {
  // ...
}

But you do need it with a simple statement like cin >> table [x]; . It's admittedly confusing at first, but you'll get it with practice.

also you will crash out past once x hits 10, your table is only of size 10

commented: Good catch =) +4
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.