| softwareStudent (17) | |
|
I'm a beginner with this whole programming thing I got my self a new programming book with a a CD with so many questions and I'm stuck with this one could some one show me how the solution would be using stdio.h and please don't make the answer so complicated for a beginner :\ Produce a program which allows the user to up to twenty positive integers. The program should store a maximum of twenty numbers and the entry of a negative number should terminate. Functions should be used to: a.Prompt the user for numbers, store them in the array and report the size of the array when the numbers have been entered. b.Calculate the minimum of the entered numbers c.Calculate the maximum of the entered numbers d.Calculate the average of the entered numbers | |
|
Last edited on
|
|
| Stewbond (1842) | |
| If we write this for you, you won't learn anything which defeats the purpose of the exercise. To do this, you'll need to use scanf() to input everything. You'll need to store the data in an array of 20. You'll also need to use a few loops. Which part are you having trouble with? | |
|
|
|
| Catfish3 (275) | |
|
I could tell you about std::min_element(), std::max_element(), std::list. But what would be the point, if yours is a C assignment, and not C++? | |
|
|
|
| softwareStudent (17) | |
| will tell me my point is also to expand my knowledge | |
|
|
|
| Catfish3 (275) | |||
|
The C++ standard has some useful built-in things that you can use, without needing to reinvent the wheel. You need to let go of certain things that C++ inherited from C, such as arrays, and use the new things C++ provides. Why? Because the new things in C++ work better with the rest of the things in C++. Finally, the C++ references are your friends. http://cplusplus.com/reference/ http://en.cppreference.com/w/
| |||
|
|
|||
| fun2code (1227) | |
|
Hi. I think you may be experiencing something which happens when you skip all the "easy" problems in the early chapters. When I arrive at a problem during self study where I am totally stumped it means that I have missed crucial concepts and must back up for review. Once I am lost I am not going to get any less lost going forward, so trying to do it anyway is pointless. You may need to back up and then take it slower. Try to work out all end of chapter exercises. It may be "boring" but it is the best way to move your skills forward solidly. | |
|
Last edited on
|
|
| softwareStudent (17) | |
| You wont believe this but I spent 9 hours and 38 min trying to solve the question I give up like seriously could some one just write the answer for me and show me the technique :| by brain is hanging upside down 0.o | |
|
|
|
| Stewbond (1842) | ||||
Here you go, but really... why didn't you post what you had spent 9 hours and 38 minutes on? We could have told you what you were doing wrong. I really have no idea what concept was hurting you.
| ||||
|
Last edited on
|
||||
| Chervil (1204) | ||
The recommended technique is to break down a large problem into a series of smaller steps.Don't just look at the whole thing and see a mountain. Break it into stages and tackle them one at a time. Some steps may be less obvious than others, and may take longer. By all means ask for help with the tricky parts. The main thing is to consider the design first. Don't think in terms of lines of code, or syntax. Think in terms of what actions need to be performed in order to carry out each step. Write those down in words, in ordinary English. Only after you have at least some sort of design should you begin to write any code. | ||
|
Last edited on
|
||
| softwareStudent (17) | |
| Thank you for youre time, the hard part was how can I allow the user to up to twenty positive integers I had know I idea how can I make that work i've never done it but Ill start analyzing the answer now so i can understand the whole concept :) | |
|
|
|