After i key in 20 different value of float, what command should i use so that i can determine the largest and smallest value from these numbers ?
Chalson
0
Newbie Poster
Recommended Answers
Jump to PostThe best way would be to calculate it during the process of input.
float s=0,l=0,x; for(int i=0;i<20;++i){ cin>>x; if(x>l) l=x; if(x<s) s=x; } /* Use the values */
Or after taking the input in an array, go through it and get the smallest and largest values.
Jump to PostRead the rules. I did just enough of the assignment to help chalson without giving him something he can turn in for homework credit.
If your was motive as this, then try not to feed in code here, give out just the pseudo code,.. if you really want it so.
…
Jump to Post@rpdm Don't get offensive/angry!! I was just pointing to some loop holes you were having in your program.. I believe that is what we are here for, helping each other..?
@mods maybe this thread is going off the topic, I would request you for it's closure..
Jump to PostYou should return EXIT_SUCCESS or EXIT_FAILURE which are in the stdlib.h file.
C99 defines that if left without a return statement it will return 0, but you should not get in the habit of doing so. What happens if one day, all hell breaks loose and EXIT_SUCCESS changes to …
All 16 Replies
elsiekins
0
Junior Poster
techie1991
26
Junior Poster in Training
rpdm
4
Newbie Poster
techie1991
26
Junior Poster in Training
rpdm
commented:
All bad points. Thanks for assuming I'm an idiot.
+0
rpdm
4
Newbie Poster
techie1991
26
Junior Poster in Training
rpdm
4
Newbie Poster
techie1991
commented:
c'mon, you are not here to fight.! are you? see my previous posts and you will come to know how idotic it is to get offensive here.!
+0
techie1991
26
Junior Poster in Training
Ketsuekiame
860
Master Poster
Featured Poster
rpdm
4
Newbie Poster
elsiekins
commented:
Rude and obnoxious
+0
Ketsuekiame
860
Master Poster
Featured Poster
rpdm
4
Newbie Poster
Ketsuekiame
860
Master Poster
Featured Poster
elsiekins
0
Junior Poster
rpdm
commented:
Why defend a slower *and* more complex solution?
+0
elsiekins
0
Junior Poster
PsychoLogic
1
Newbie Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.