From: Per W. <pw...@ia...> - 2004-07-04 22:30:35
|
You have forgotten then end brace for your for() statement. Note that you shouldn't use the for statement like that, since you don't want to run it for 20 times, but until you have 20 accepted numbers. If a user enters an incorrect number, the for loop should run for more than 20 times. With your current structure, you do one retry if the entered number iswrong - however, you don't make a new check that the number is ok. If you instead did the i++ increment only when you are satisfied with the number, you may run the for loop as many times as is needed. You should add a new loop (for j = 0; j < i; j++) to verify that the entered number isn't a duplicate value. By the way: Please specify a subject when you mail to this list. /Per W On Sun, 4 Jul 2004, PETER CAMPOS wrote: > cpp freshman asks for help again...i want this program to request the user for 20 numbers within the range 10<x<100 and print the 20 numbers. if the numbers have any duplicates the numbers must be re-entered. > i have a parse error at the end of the program. i've read thru the program a few times but can't find it. **David, i am trying to think more about my programs and what i want them to do. i made a flow chart for this one. another question, is it possible to use rand()/rand_max in anyway in this program? > > thanx again everyone > panos.....GO GREEECE EURO 2004:) > > #include <iostream> > using namespace std; > > int main(){ > int numbs; > int num[20]; > for (int i=0; i<20; i++){ > cout << "what are the numbers? "; > cin >> numbs; > num[i] = numbs; > > if (num[i] = num[i]) > { > cout << "you have entered a duplicate. Try again. "; > cin >> numbs; > num[i] = numbs; > } > > else if (numbs <= 10 || numbs >= 100) > { > cout << "you have entered a value out of range. try again. "; > cin >> numbs; > num[i] = numbs; > } > else > cout << "the numbers are" << num[i] << endl; > > > return 0; > } > > > ______________ ______________ ______________ ______________ > ccny.cuny.edu > > > > > > > ------------------------------------------------------- > This SF.Net email sponsored by Black Hat Briefings & Training. > Attend Black Hat Briefings & Training, Las Vegas July 24-29 - > digital self defense, top technical experts, no vendor pitches, > unmatched networking opportunities. Visit www.blackhat.com > _______________________________________________ > Dev-cpp-users mailing list > Dev...@li... > TO UNSUBSCRIBE: http://www23.brinkster.com/noicys/devcpp/ub.htm > https://lists.sourceforge.net/lists/listinfo/dev-cpp-users > |