944,101 Members | Top Members by Rank

Ad:
  • C++ Discussion Thread
  • Unsolved
  • Views: 1365
  • C++ RSS
Apr 8th, 2006
0

I'm new in this site and also in c++, please help me

Expand Post »
Hi everyone,

First I want to say hello to everybody in this site and I hope that you'll welcome me as one of your nice members :o .
I've just started learning C++ language, and now I have to make a small program that counts the average grade for a number of homeworks for a number of students. This program should count only the big grades and leaves the last small grade, like if the user entered (56, 67, 98, 45, 67, 46, 89) the program would add them all together except the last small one which is 45, and then devide them by their number 6 and not 7. I have to put this inside a loop and also I need to use an if statement. I know how to do everything, but I just need to know how to make the part when the program should look for the smallest grade and ignore it. Please help guys and thanks inadvance
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
almared_6 is offline Offline
3 posts
since Apr 2006
Apr 8th, 2006
0

Re: I'm new in this site and also in c++, please help me

I would use an array to store the numbers.

Hint: Loop through the array and use the comparison operator to find the smallest number.
Featured Poster
Reputation Points: 1536
Solved Threads: 431
Posting Expert
iamthwee is offline Offline
5,865 posts
since Aug 2005
Apr 9th, 2006
0

Re: I'm new in this site and also in c++, please help me

yah.... using array is good idea for beginners..... n don't forget to subtract 1 from the total element number before finding the avg.... .... as i used to do such mistakes a lot!

*** after finishing ur coding, ask if u r still in any trouble!
Reputation Points: 46
Solved Threads: 11
Junior Poster
orko is offline Offline
164 posts
since Apr 2006
Apr 9th, 2006
0

Re: I'm new in this site and also in c++, please help me

thanks for replying. The arrys seem good but I havent studied it yet, Im supposed to learn it in two weeks. So, is there any other way? and is there anyway to show how to do it because as I said I,ve just started

Thanks again
Reputation Points: 10
Solved Threads: 0
Newbie Poster
almared_6 is offline Offline
3 posts
since Apr 2006
Apr 9th, 2006
0

Re: I'm new in this site and also in c++, please help me

All you need is a record of the total, and a record of the smallest.
When you're done, subtract the smallest from the total, and calculate the average.
No arrays necessary.
Team Colleague
Reputation Points: 5862
Solved Threads: 950
Posting Sage
Salem is offline Offline
7,164 posts
since Dec 2005
Apr 11th, 2006
0

Re: I'm new in this site and also in c++, please help me

ya that's ok with me, but how do I get a record with the smallest? That's the question that I'm trying to find an answer for.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
almared_6 is offline Offline
3 posts
since Apr 2006
Apr 12th, 2006
0

Re: I'm new in this site and also in c++, please help me

Quote originally posted by almared_6 ...
ya that's ok with me, but how do I get a record with the smallest? That's the question that I'm trying to find an answer for.
Get first entry and put it in a variable 'smallest'
qty = 0; // why zero here and not at the beginning? food for thought.
Now loop though each entry comparing new entry to smallest.
Remember to keep track of the qty of entries.
if newentry is less {
...
} else {
...
}
average = total/qty;

That should be enough to get you started.
Reputation Points: 11
Solved Threads: 0
Light Poster
Nedals is offline Offline
43 posts
since Dec 2005
Apr 12th, 2006
0

Re: I'm new in this site and also in c++, please help me

Quote originally posted by almared_6 ...
ya that's ok with me, but how do I get a record with the smallest? That's the question that I'm trying to find an answer for.
How would you do it in real terms? Imagine someone calling out bingo numbers, and you're looking out for the smallest.
The first time he calls out a number, you remember that number, because it's the smallest number he's called so far.
Second time, you ask yourself "is this smaller than the smallest number?"
if the answer is yes, you remember that one
if not, you wait for the 3rd number... etc.
Reputation Points: 307
Solved Threads: 62
Posting Pro
Bench is offline Offline
565 posts
since Feb 2006

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C++ Forum Timeline: Snmp Mib
Next Thread in C++ Forum Timeline: Word length sorting





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC