![]() |
| | #1 |
| Registered User Join Date: Mar 2005
Posts: 60
| average in an array |
| s_ny33 is offline | |
| | #2 |
| and the hat of Jobseeking Join Date: Aug 2001 Location: The edge of the known universe
Posts: 21,689
| Well can you calculate the average or not? Then it's simply cout << score - average; |
| Salem is offline | |
| | #3 |
| Registered User Join Date: Mar 2002
Posts: 1,595
| for those scores below average, subtracting average from score will be negative. If you want to be able to say "Current score is x points below average" rather than "current score is -x points", then you can do something like: result = abs(score - average) to show the difference whether it is higher or lower than the average (that is, the absolute value of the difference), or, if you aren't supposed to use abs(), or equivalent, you can roll your own by doing something like assign score - average to result if result is greater than zero output results otherwise assign minus one times result to result output results
__________________ You're only born perfect. |
| elad is offline | |
![]() |
| Thread Tools | |
| Display Modes | |
|
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Modify an single passed array element | swgh | C Programming | 3 | 08-04-2007 08:58 AM |
| 2d array question | gmanUK | C Programming | 2 | 04-21-2006 12:20 PM |
| question about multidimensional arrays | richdb | C Programming | 22 | 02-26-2006 09:51 AM |
| average of array elements? | swapnil_sandy | C Programming | 2 | 12-02-2005 12:16 PM |
| Template Array Class | hpy_gilmore8 | C++ Programming | 15 | 04-11-2004 11:15 PM |