I'm trying to find the average of the numbers inputed by the user. For example the user inputs: 23, 23, 4, 6.
I want to add them and than divide by the number of times inputed which is 4. Is there a procedure I can call to do this quickly or would I have to write an addition and division algorithm for it. Any hints are welcome.
This sounds like homework or class assignment.....
You will have to write your own code, there is no API functions for this. And i wouldn't recommend any particular library functions for it either, because if you use those then you are not learning how to take input, treat ASCII as numbers, manipulate it, convert it back to ASCII, and output it.
Check the documentation that comes with your MASM32 install, there are macros that convert ASCII to numbers and back again. But you really should study the macros and understand what they are doing before you use them, as macros are expanded out at compile time, and if your tutor disassembles your code he may want to ask you what is happening :U
hmmmm,
This does sound like homework. If you need help with assembler questions feel free to post them in here but don't post homework questions or we will remove them and your membership with it.
No this is not homework. If you look at my other post, I have already finished my calculator program. This is just out of mere interest.
Quote from: Pro32 on April 02, 2005, 12:50:16 AM
No this is not homework. If you look at my other post, I have already finished my calculator program. This is just out of mere interest.
Okay, but you really should post code, or make your questions more specific :8)
OK, the adds are the easy part but if you want any real precision, you will do all of this stuff in 80 bit floating point. Have a good look at Ray Filiatreault's FP tutorial as it has the technical data you need to get the required precision.
As you're adding the numbers up, keep count of how many numbers you've added.
Then once you're done, use DIV with the count_of_numberrs_added.
ok thanks for the help. I'll see what I can do. I'll post code as soon as I tweak it.