# Thread: Help to write min,max program for a project

1. ## Help to write min,max program for a project

I have an assigment and I don't know yet how to write this program :" I introduce the average monthly temperatures of a year(12 values for 12 months). When I compile the program it needs to show the highest negative temparature and the lowest positive temperature of that year. Example: Entry data: -4 -6 0 5 10 20 24 25 17 8 -1 -7 exit data : max negative= -1 and min positive= 5 "

I can pay a few dollars through paypal but I'm from Romania so I don't have much, I need the program in maximum 12 hours from now, please help.

1. Write a program to get the monthly temperatures and print them. This will give me confidence that I can do the basic input and output correctly. After that, I can work on the core algorithm of the exercise.

2. Hard code a suitable set of month temperatures, design and implement an algorithm to find the maximum negative temperature, and then print it. This will give me confidence that I can do the algorithm that forms the core of the exercise. After that, I can figure out how to change it to also find the minimum positive temperature (what about 0 degrees?), and get it to read input properly.

Pick one of these two approaches and get started. If you get stuck, you can ask for help by posting your current program and explaining how does it not work.

3. @laserlight thank you, I understand that you're REALLY wanting to help me by guiding me,I really do, but I just started to learn C and I find it very difficult for my head, I just want to do this project for a minimal grade at school, I don't think I can become a programmer, if someone can write the whole program I'll pay for it, 5\$ or 10\$ whatever they ask,please help, it's very important for me to pass the course.

4. Originally Posted by nightwolf9ss
I just started to learn C and I find it very difficult for my head
That's why both the approaches I described does not require you to do everything at once: solve the problem by breaking it down into steps, thus solving it step by step. To solve a particular step, you might need to review your learning material, ask for help in understanding it, or even experiment and break it down into smaller steps, etc.

Originally Posted by nightwolf9ss
I just want to do this project for a minimal grade at school, I don't think I can become a programmer, if someone can write the whole program I'll pay for it, 5\$ or 10\$ whatever they ask,please help, it's very important for me to pass the course.
I could say the same thing about pretty much any subject at school: I don't think I can become a professional mathematician; I don't think I can become a professional historian. It would not change the fact that getting/paying someone else to do my maths homework or write my history essay would be cheating. Academic dishonesty could result in an immediate failure of the course, perhaps even expulsion from your academic institution, so if it is very important for you to pass the course, then you should start working on your assignment, step by step.

5. if you stopped looking to buy the solution and tried to do it for yourself, you would find that 12 hours is more than enough time to come up with a solution to your task.

6. If you remain calm, and work on it, you have time.

The problem is no different from someone handing you a bunch of coins, and asking you to find the one that is worth the most, and the one that is worth the least, out of the coins. You would need to compare every coin to the coin that was the previous maximum, as well as the previous minimum, correct?

Sounds like a loop could be used here, doesn't it?

Code:
```for( each coin)
{
if the coin is > the value of the maximum coin found so far,
then the coin value becomes the new max value.

if the coin is < the value of the minimum coin found so far,
then the coin values becomes the new min value.
}```
The above is the basic logic you would use, but the silly computer (lacking common sense), won't know how to set the initial max and min values. With coins you could start at zero, since there are no negative values possible. With temperatures, negative values are common though. One answer is to set the maximum and minimum values to the first value you look at, before the for loop starts. Then start the for loop, comparing the second value, instead of the first one.

Remember that in C, you want to use arrays for this, and array indices start at zero, not one. So the first value is array[0], second value is array[1], etc.

7. Thank you all for trying to help me, you were right ,I got the program "ready made" and the teacher asked me if I wrote it and I had to tell her I did not and the look on her face..... I felt ashamed the whole day, I'm not very young anymore and learning new things come hard for me but still I should've tried,my bad.

8. The teacher probably had a fair inkling you hadn't done the work, otherwise she wouldn't have asked the question.

Students the world over think they can fool teachers. The problem is, since most teachers are or were students themselves, most know the tricks that get created (ahem, reused) by each new group of students. Every new crop of students think they have created a new way to fool teachers without doing the work, but very few actually have.

If the teacher actually knows something about the subject, s/he is even more likely to pick up a cheating student. It is easy for a novice to trick a novice. The chances of a novice tricking an expert are remote.

9. Lol yah you can take the program for the internet that's normal

but at least try to study what did u take and understand it

10. Lol yah you can take the program for the internet that's normal
Sadly, it is normal. When I went to school, several people spent a lot of energy collecting programs that were solutions for all laboratory assignments. I was often offered these solutions from one particular individual. I always turned them down because, well, I wanted to actually learn it on my own. I ran into that guy last year. He works at a Volkswagen dealership, whereas I hold an engineering position. If he spent as much energy learning the material as he did in trying to acquire a comprehensive set of solutions written by others, perhaps he would have better employment today.

but at least try to study what did u take and understand it
I'd argue that, at best, one would only understand a tiny fraction of the solution. A person might think they understand something when they see it written out for them - but it's only when trying to write it oneself that true understanding can begin to be achieved.

11. I'd argue that, at best, one would only understand a tiny fraction of the solution. A person might think they understand something when they see it written out for them - but it's only when trying to write it oneself that true understanding can begin to be achieved.
i can testify

12. I'd agree, but the simple concepts are easily grasped just by a quick perusal. For instance, my neighbor's border collie was over visiting, saw my post above, and was immediately able to use it in a small C snippet of code. <smile>