0
How can I write a function that return the minimum and maximum of 6 numbers ?
13 Antworten
+ 3
Mayank, I fully agree with what you wrote and hereby officially withdraw my code.
R_Defao, if you already looked at my code, please wash your eyes with soap and try to forget everything you saw.
You can find the minimum and maximum of an array of numbers by creating two variables, e.g. min and max (or you can use pointers) and set both of them to the first item of the array. Then you iterate over the array and whenever you find a number that is larger than the number currently held in max, set/point max to that number (same with min).
+ 2
KrOW, calm down. There are different learning types. A lot of people learn better if they see how somebody does the job and try to comprehend/recreate it. In fact, that's how pretty much every tutorial works.
If somebody isn't interested or doesn't want to learn (I'm not talking about R_Defao), you won't change that by telling him to do everything on their own.
Also, usually teachers won't just check if the homework was done, but they will actually discuss it and if the student isn't able to explain what "his" code does, it's pretty obvious that he didn't write it on his own. Teachers aren't that stupid.
+ 2
KrOW Anna Although i agree there are different people learning differently, but still i feel people should atleast provide their own try before asking a question, obviously people understand better if they see someone else create the solution, but they can do that even after trying it themselves once, infact that would even make the learning process better than not trying at all.
Personally speaking, when i encounter any problem which i know i cant solve i still first try to solve it so i know where i got stuck and when i look at solution i get a greater clarity of concepts after that, so if there's a rule for homework questions to submit your own try first, i feel that would be beneficial to learners overall
+ 2
Anna I dont ask they to make all own... If they dont understand something, they can ask for details about concepts and not for full code. If next they dont post their try (or something that show their problem) its oblivious what really they want (and is not learn)... Futhermore i want make you a question... You know thats is very easy problem and he ask for a solution. How he can understand your code (that use pointer and its not the easy way to resolve the problem) if he cannot resolve his problem?
Mayank I agree fully with you
+ 1
if you know how get minimum/maximum between two numbers, you can extend to any numbers count
+ 1
Can you give me a code sample
+ 1
Thanks.
+ 1
Some users here dont understand that many questions are posted for get easy solutions to homeworks... You think that posting full solution codes help to learn who make question? The answer is maybe.. Maybe he/she can learn from your code, maybe he/she use your code as own solution and dont learn nothing asking anymore at next problem without apply itself.... In the doubt i prefer that who ask give me a "proof" that he/she want learn then i try to make he/she think about the problem because ONLY in this way you are SURE to help
+ 1
R_Defao The problem from my point of view is that you posted nothing for show that you apply for solve your problem (min/max of 6 numbers)
P.S you can post only needed code
0
R_Defao Instead to wait for my code, why you dont post what you did for now? Start with post a code for check minimim/maximum between 2 numbers
0
R_Defao From your answer i understanded that you want a solution to your problem WITHOUT apply yourself.. Well, dont work so here... Hardly someone make YOUR assignements for YOU. Anyway you are welcome
0
/Edit: redacted (see below)