|
From: Wehrli, L. <we...@st...> - 2004-07-04 22:46:00
|
=20
Hi Peter,
=20
1.) Rhetoric question: where does your for-loop end?
2.) Don't forget to end cout << ".." statements with a << endl
3.) if (num[i] =3D num[i]) ? You would probably want to loop over all =
previous inserted numbers here. Don't forget to use =3D=3D (and not =3D) =
for comparisons!
4.) The two checks inside the for-loop should probably also hold for =
corrected numbers, so is a if-statement the right tool? What if the user =
types "3", and then again "3", and again...
hope that helps,
Lior
________________________________
Von: dev...@li... im Auftrag von PETER =
CAMPOS
Gesendet: So 04.07.2004 21:43
An: dev...@li...
Betreff: [Dev-C++] (no subject)
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.=20
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=3D0; i<20; i++){
cout << "what are the numbers? ";
cin >> numbs;
num[i] =3D numbs;
=20
if (num[i] =3D num[i])
{
cout << "you have entered a duplicate. Try again. ";
cin >> numbs;
num[i] =3D numbs;
} =20
=20
else if (numbs <=3D 10 || numbs >=3D 100)
{ =20
cout << "you have entered a value out of range. try =
again. ";
cin >> numbs;
num[i] =3D numbs; =20
} =20
else
cout << "the numbers are" << num[i] << endl;
=20
=20
return 0;
}
______________ ______________ ______________ ______________
ccny.cuny.edu
=20
-------------------------------------------------------
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
|