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:
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:
>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
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.