![]() |
|
#1
|
|||
|
|||
Something's wrong w/my program.Hi. My program is supposed to find the median. Originally, I arranged the variable median to be int, but I realized that for medians of even sets of numbers, it would make more sense to set median to float. So here's what I got:
CPP / C++ / C Code:
But now, I can't run the program because there are 3 errors, all saying: Compiling NONAME08.CPP: Error NONAME08.CPP 27: Illegal use of floating point in function main() Error NONAME08.CPP 32: Illegal use of floating point in function main() Error NONAME08.CPP 32: Illegal use of floating point in function main() What did I do wrong? Thank You. |
|
#2
|
|||
|
|||
|
Quote:
It's telling you that an array index must be an int. Now, for even sets of numbers the median value may very be a non-integer, as your program tries to compute. One way to handle it is to have an int variable for the array index, and a float variable for the median itself. I think the logic in your program is OK; here's a suggestion for getting it to work: CPP / C++ / C Code:
Regards, Dave |
Recent GIDBlog
Meeting the populace by crystalattice
| Thread Tools | Search this Thread |
| Rate This Thread | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| [TUTORIAL] Calling an external program in C (Linux) | dsmith | C Programming Language | 4 | 22-Apr-2005 13:30 |
| RSA program | fwongmc | C Programming Language | 11 | 08-Nov-2004 22:15 |
| Anyone can write a program code for this??? | chriskan76 | C Programming Language | 1 | 19-Oct-2004 20:25 |
| Need help with a C program (Long) | McFury | C Programming Language | 3 | 29-Apr-2004 20:06 |
| one program access another? | dgoulston | C++ Forum | 1 | 07-Oct-2003 11:26 |
Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The