English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

#include
using namespace std;
#define MAX 20

int main()
{
int num[MAX];
int index;
int more;
int count = 0;


std::cout<< "Enter A num";
std::cin >> num[count];
std::cout << "Enter more NUM(y/n)";
std::cin >> more;

if(more == 'n')
{
break;
}
else
{
count++;
}


for(index =0;index <= count; index++)
{
std::cout << "ELEMENT IN " << (index + 1) << "is" << num[index];
system("PAUSE");
}
cout << endl << "Array Element Used =" << (count + 1) ;

return 0;
}

error illegal break;

can u explain me 1 thing what does the num[index] means especialy the "[ ]" parts thanks.

2006-11-21 14:32:25 · 2 answers · asked by Best Helper 4 in Computers & Internet Programming & Design

2 answers

YAY a C question I can help with!!! I hope you know a little about programming tho..sorry.

First of all num[index] is an array which have multiple variables in them right? The [ ] signify an array. You said that num[max] will have 20 variables (at most) at the top of the program but forget about that because it's doesn't serve a purpose in this prog.

OK, I've gotta stop, looking at this program you've gotta lot of logical errors. But in essence you're asking the program to run the for loop until the index value in num[index] is equal to whatever the number is in count at the end...

Email me if you want some more help though!

2006-11-21 14:42:22 · answer #1 · answered by aeseeke 3 · 0 0

Surely, your 'break' is illegal: break can appear within any loop (for, do, while) or within case switch. In your function body you need return instead though it has no sense in main().

2006-11-21 23:25:04 · answer #2 · answered by alakit013 5 · 0 0

fedest.com, questions and answers