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

Please support our C++ advertiser: Intel Parallel Studio Home
Reply

Join Date: Apr 2006
Posts: 3
Reputation: almared_6 is an unknown quantity at this point 
Solved Threads: 0
almared_6 almared_6 is offline Offline
Newbie Poster

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

 
0
  #1
Apr 8th, 2006
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
Reply With Quote Quick reply to this message  
Join Date: Aug 2005
Posts: 5,266
Reputation: iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold 
Solved Threads: 377
Featured Poster
iamthwee's Avatar
iamthwee iamthwee is offline Offline
Posting Expert

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

 
0
  #2
Apr 8th, 2006
I would use an array to store the numbers.

Hint: Loop through the array and use the comparison operator to find the smallest number.
*Voted best profile in the world*
Reply With Quote Quick reply to this message  
Join Date: Apr 2006
Posts: 164
Reputation: orko is an unknown quantity at this point 
Solved Threads: 10
orko orko is offline Offline
Junior Poster

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

 
0
  #3
Apr 9th, 2006
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!
A Perfect World
Reply With Quote Quick reply to this message  
Join Date: Apr 2006
Posts: 3
Reputation: almared_6 is an unknown quantity at this point 
Solved Threads: 0
almared_6 almared_6 is offline Offline
Newbie Poster

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

 
0
  #4
Apr 9th, 2006
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
Reply With Quote Quick reply to this message  
Join Date: Dec 2005
Posts: 5,850
Reputation: Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute 
Solved Threads: 749
Team Colleague
Salem's Avatar
Salem Salem is offline Offline
Void main'ers are DOOMed

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

 
0
  #5
Apr 9th, 2006
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.
Reply With Quote Quick reply to this message  
Join Date: Apr 2006
Posts: 3
Reputation: almared_6 is an unknown quantity at this point 
Solved Threads: 0
almared_6 almared_6 is offline Offline
Newbie Poster

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

 
0
  #6
Apr 11th, 2006
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.
Reply With Quote Quick reply to this message  
Join Date: Dec 2005
Posts: 43
Reputation: Nedals is an unknown quantity at this point 
Solved Threads: 0
Nedals Nedals is offline Offline
Light Poster

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

 
0
  #7
Apr 12th, 2006
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.
Reply With Quote Quick reply to this message  
Join Date: Feb 2006
Posts: 490
Reputation: Bench has a spectacular aura about Bench has a spectacular aura about Bench has a spectacular aura about 
Solved Threads: 49
Bench's Avatar
Bench Bench is offline Offline
Posting Pro in Training

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

 
0
  #8
Apr 12th, 2006
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.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the C++ Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC