|
From: nuc p. <nuc...@ms...> - 2004-07-05 07:40:32
|
<html><div style='background-color:'><DIV class=RTE>
<P>hey lior, your response did help me out but i have some questions. thanx. </P>
<P>i fixed the comparison using == not = and i closed the for loop with a }. i also used endl at the end of cout statements. that takes care of a few problems.</P>
<P>what do you mean by "if (num[i] == num[i]) ? You would probably want to loop over all previous inserted numbers here" ? </P>
<P>also, by the following:</P>
<P>"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..."</P></DIV>
<DIV></DIV>
<P>i was hoping that if num[i] == num[i] the program would return back to the initial cout statement prompting the user to re-enter the numbers. i now realize that the statement will always be false: if the numbers are duplicates or not the array will always equal itself and thus the out put will always be "you have entered a duplicate number."</P>
<P>back to the drawing board...any additional comments from anyone would be a great help.</P>
<P>thanx.</P>
<P>peter/panos</P>
<P>>From: "Wehrli, Lior" <we...@st...> </P>
<DIV></DIV>>To: <dev...@li...>
<DIV></DIV>>Subject: AW: [Dev-C++] (no subject)
<DIV></DIV>>Date: Mon, 5 Jul 2004 00:43:12 +0200
<DIV></DIV>>
<DIV></DIV>>
<DIV></DIV>>Hi Peter,
<DIV></DIV>>
<DIV></DIV>>1.) Rhetoric question: where does your for-loop end?
<DIV></DIV>>2.) Don't forget to end cout << ".." statements with a << endl
<DIV></DIV>>3.) if (num[i] = num[i]) ? You would probably want to loop over all previous inserted numbers here. Don't forget to use == (and not =) for comparisons!
<DIV></DIV>>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...
<DIV></DIV>>
<DIV></DIV>>hope that helps,
<DIV></DIV>>
<DIV></DIV>>Lior
<DIV></DIV>>
<DIV></DIV>>
<DIV></DIV>>________________________________
<DIV></DIV>>
<DIV></DIV>>Von: dev...@li... im Auftrag von PETER CAMPOS
<DIV></DIV>>Gesendet: So 04.07.2004 21:43
<DIV></DIV>>An: dev...@li...
<DIV></DIV>>Betreff: [Dev-C++] (no subject)
<DIV></DIV>>
<DIV></DIV>>
<DIV></DIV>>
<DIV></DIV>>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.
<DIV></DIV>>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?
<DIV></DIV>>
<DIV></DIV>>thanx again everyone
<DIV></DIV>>panos.....GO GREEECE EURO 2004:)
<DIV></DIV>>
<DIV></DIV>>#include <iostream>
<DIV></DIV>>using namespace std;
<DIV></DIV>>
<DIV></DIV>>int main(){
<DIV></DIV>> int numbs;
<DIV></DIV>> int num[20];
<DIV></DIV>> for (int i=0; i<20; i++){
<DIV></DIV>> cout << "what are the numbers? ";
<DIV></DIV>> cin >> numbs;
<DIV></DIV>> num[i] = numbs;
<DIV></DIV>>
<DIV></DIV>> if (num[i] == num[i])
<DIV></DIV>> {
<DIV></DIV>> cout << "you have entered a duplicate. Try again. ";
<DIV></DIV>> cin >> numbs;
<DIV></DIV>> num[i] = numbs;
<DIV></DIV>> }
<DIV></DIV>>
<DIV></DIV>> else if (numbs <= 10 || numbs >= 100)
<DIV></DIV>> {
<DIV></DIV>> cout << "you have entered a value out of range. try again. ";
<DIV></DIV>> cin >> numbs;
<DIV></DIV>> num[i] = numbs;
<DIV></DIV>> }
<DIV></DIV>> else
<DIV></DIV>> cout << "the numbers are" << num[i] << endl;
<DIV></DIV>>
<DIV></DIV>>
<DIV></DIV>>return 0;
<DIV></DIV>>}
<DIV></DIV>>
<DIV></DIV>>
<DIV></DIV>>______________ ______________ ______________ ______________
<DIV></DIV>> ccny.cuny.edu
<DIV></DIV>>
<DIV></DIV>>
<DIV></DIV>>
<DIV></DIV>>
<DIV></DIV>>
<DIV></DIV>>
<DIV></DIV>>-------------------------------------------------------
<DIV></DIV>>This SF.Net email sponsored by Black Hat Briefings & Training.
<DIV></DIV>>Attend Black Hat Briefings & Training, Las Vegas July 24-29 -
<DIV></DIV>>digital self defense, top technical experts, no vendor pitches,
<DIV></DIV>>unmatched networking opportunities. Visit www.blackhat.com
<DIV></DIV>>_______________________________________________
<DIV></DIV>>Dev-cpp-users mailing list
<DIV></DIV>>Dev...@li...
<DIV></DIV>>TO UNSUBSCRIBE: http://www23.brinkster.com/noicys/devcpp/ub.htm
<DIV></DIV>>https://lists.sourceforge.net/lists/listinfo/dev-cpp-users
<DIV></DIV>>
<DIV></DIV>>
<DIV></DIV>>
<DIV></DIV>>
<DIV></DIV>>-------------------------------------------------------
<DIV></DIV>>This SF.Net email sponsored by Black Hat Briefings & Training.
<DIV></DIV>>Attend Black Hat Briefings & Training, Las Vegas July 24-29 -
<DIV></DIV>>digital self defense, top technical experts, no vendor pitches,
<DIV></DIV>>unmatched networking opportunities. Visit www.blackhat.com
<DIV></DIV>>_______________________________________________
<DIV></DIV>>Dev-cpp-users mailing list
<DIV></DIV>>Dev...@li...
<DIV></DIV>>TO UNSUBSCRIBE: http://www23.brinkster.com/noicys/devcpp/ub.htm
<DIV></DIV>>https://lists.sourceforge.net/lists/listinfo/dev-cpp-users
<DIV></DIV></div><br clear=all><hr> <a href="http://g.msn.com/8HMAENUS/2755??PS=47575">Is your PC infected? Get a FREE online computer virus scan from McAfee® Security.</a> </html>
|