We start seeing questions like:
A car dealer has 10 salespersons. Each salesperson keeps track of the number of cars sold each month and reports it to the management at the end of the month. The management keeps the data in a file and assigns a number, 1 to 10, to each salesperson....
Write the code to store the number of cars sold by each salesperson in the array cars, output the total numbers of cars sold at the end each month, and output the salesperson number selling the maximum number of cars. (Assume that data is in the file cars.dat, and that this file has been opened using the ifstream variable inFile.)
The first thing to understand is that we are not a code writing service. You can't just copy/paste a homework into the text area and expect someone to do your homework for you.
Programmer education builds upon previous experiences. The compiler class has machine language and data structures as prerequisites because if you don't understand those, you will be hopelessly lost in the class and not even able to understand the lectures.
Lets assume you do understand the code (the person answering the question did a good job explaining it)... the curriculum is designed to take you from
Z with 24 steps between. As industry programmers we often take shortcuts and don't need say, steps
ijkl to do something. Learning from us, you'll never get these steps. However you may find in your next assignment or class that understanding
jk is assumed and critical to the understanding of some other concepts. Just because we don't need
ijkl to do it doesn't mean it isn't understood.
A programming class I took years ago used SPIM - a MIPS simulator. One of the students discovered a little-used DECStation in the lab that had gcc on it. Instead of writing the assignment (factorial) by hand with the concepts we had access to (we were supposed to write a recursive function to learn about the stack and frame pointer), he wrote it in C, compiled it with
gcc -S and handed in the resulting MIPS assembler code. However, the compiler, recognizing an optimization, converted the entire code from a recursive subroutine into a
for loop. He got a '0' on that homework and had trouble with the next one (which assumed you already understood the frame pointer and stack pointer).
Copy and paste takes no skill. It cheats you out of the education you are paying to get.
It cheats us of good interview candidates. Technical interviewers often complain about the quality of college graduates. You may be enthusiastic, but unless you can write code and explain concepts better than the other guy, we're going to hire the other guy.
Your first resource to look at should be your instructor. They are there for you and want to have you follow a specific path to get to the end point of understanding.
So, you've exhausted the resources. You've tried asking your instructor. You've searched google. You've gone over your lecture notes and even knocked on the TA's door during office hours. And you've come here...
Don't expect an answer in any given time frame. The urgency of your question is not something we are concerned with. Good questions and answers are timeless - not something that needs to be done by 5pm today or 8am on Monday (you may find the rate of answers drops substantially on the weekends and evenings of various timezones).
Describe the problem you are having, what your understanding of the problem is and where you are confused. For a question from a student, the best questions are often the ones that are asking how to take a single step in understanding rather than trying to leap all the way to the solution.
Realize also that the answer we give you may be completely wrong for the path that your instructor is trying to get you to follow. Having previously fought through the problem ourselves, we know and understand when one can jump directly from
il and when one needs to go through each step of
ijkl in a process. Our answers may skip over steps that aren't needed for this particular problem, but may be critical for understanding the next assignment or some problem years down the road where skipping
jk is the wrong answer. In many cases, it is important to follow the curriculum as best as you are able. Going above and beyond is good where one gains a deeper understanding of a problem domain, but one must have the foundation upon which to build.
We want you to do your homework to the best of your ability. Getting points off on an assignment and learning something from that produces a better interview candidate than one who can copy and paste code that got As in school but can't solve a simple problem they've never seen before.
If you decide to post your question anyway
Please make sure you read the tour and help center. Programmers focuses on software design and architecture. Questions about "how to write some code" or "help me debug this code" are off topic on Programmers.SE as they are issues with implementation rather than design. They may be on topic on Stack Overflow, but just posting the requirements or code and saying what amounts to "help me" is rarely enough for a good question - make sure you read How to create a Minimal, Complete, and Verifiable example before posting a question on Stack Overflow.
If your question on Programmers.SE is just a copy paste of homework problem, expect it to be downvoted, closed, and deleted - potentially in quite short order.