•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the C++ section within the Software Development category of DaniWeb, a massive community of 455,968 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,746 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our C++ advertiser: Programming Forums
Views: 516 | Replies: 5
![]() |
| |
•
•
Join Date: Oct 2007
Posts: 49
Reputation:
Rep Power: 2
Solved Threads: 0
how would i write a maximum number test function that will take any number of arguments and returns the greatest of them???
i know i need to used recursion function, but how should i declare the function??
here is what i have so far
i know i need to used recursion function, but how should i declare the function??
here is what i have so far
c++ Syntax (Toggle Plain Text)
double maxNumber( double inputNum,A double inputNumB) { double finalNum; if inputNumA > inputNumB { finalNum == inputNumA return inputNumA; }}
Last edited by Ancient Dragon : Nov 25th, 2007 at 10:37 am. Reason: corrected code tags
•
•
Join Date: Oct 2007
Location: Cherry Hill, NJ
Posts: 1,878
Reputation:
Rep Power: 13
Solved Threads: 193
> how would i write a maximum number test function that will take any number of arguments and returns the greatest of them???
I think it would be very odd that your professor wants you to create a function that takes a variable number of arguments. Perhaps you should work with finding the largest number in an array?
Don't use recursion unless your professor explicitly asked you to. I don't imagine he did if you are to work with a variable number of numbers...
To figure out your problem, you have to think about how you, yourself can find the largest number in a list. For example, if I give you the following numbers, which is largest?
Figure out how you figure it out on your own, and then you can tell the computer how to figure it out. Make sense?
Hope this helps.
I think it would be very odd that your professor wants you to create a function that takes a variable number of arguments. Perhaps you should work with finding the largest number in an array?
Don't use recursion unless your professor explicitly asked you to. I don't imagine he did if you are to work with a variable number of numbers...
To figure out your problem, you have to think about how you, yourself can find the largest number in a list. For example, if I give you the following numbers, which is largest?
•
•
•
•
1295876
1279553
1295976
1297854
Hope this helps.
![]() |
•
•
•
•
•
•
•
•
DaniWeb C++ Marketplace
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
Similar Threads
- Need help writing a function (Visual Basic 4 / 5 / 6)
- Need help writing this function (C)
- Pointer and function (C++)
- Lisp help - is this function right? (Legacy and Other Languages)
- writing method (Java)
- traverse function doubly linked list (C)
- Stuck writing a Function (C++)
- writing an array to a file (C++)
Other Threads in the C++ Forum
- Previous Thread: please send answer until 26.11.2007
- Next Thread: Arrays



Hybrid Mode