![]() |
|
#1
|
|||
|
|||
Non-Recursive functionI don't understand the concept of non-recursive functions. If I am to write a non-recursive function, not using bitwise operations, to print out a non-negative number in binary, how would I do it?
I know that for the recursive function: CPP / C++ / C Code:
I don't know if it is so basic that I am missing it, but I just can't seem to wrap my mind around doing it non-recursively. Any help would be greatly appreciated. |
|||
|
#2
|
|||
|
|||
Re: Non-Recursive functionQuote:
CPP / C++ / C Code:
Code:
Quote:
Most likely, this won't be clear the first time through. It may not be clear by the third time through, but write some more examples in code, & step through execution. If you want to use a debugger, great. Otherwise, throw in lots of cout statements. If you still have questions, feel free to post them here, but make your questions specific. The goal of anyone here is to help you find the solution yourself. Simply providing you the final answer doesn't help you refine your troubleshooting skills; providing you the answer only refines the ability to beg. |
|
#3
|
|||
|
|||
Re: Non-Recursive functionQuote:
You cannot simply cout the result this way; you have to store it somewhere. It could look like... CPP / C++ / C Code:
CPP / C++ / C Code:
Second, your 'base' parameter is useless. In fact, it's even more, it's misleading! When I read that I think I'm supposed to provide an integer and the base for the integer. But alas, no, I'm supposed to provide the base for... Binary? Really... Can a binary system REALLY be in any other base than 2? Third, since you say "unsigned integer", shouldn't your first argument reflect this somehow? Perhaps 'unsigned int' for the type would be more suitable? Fourth, your function body is a bit misleading too. What you actually do is this: CPP / C++ / C Code:
|
Recent GIDBlog
Vista ?Widgets? on Windows XP by LocalTech
| Thread Tools | Search this Thread |
| Rate This Thread | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| run script command on ns2.26 | newbie06 | Computer Software Forum - Linux | 66 | 16-Jan-2010 10:53 |
| Compiling C btrieve programs in VS 2005 | emanresu | C Programming Language | 1 | 16-Nov-2009 03:19 |
| Problem executing nam-1.13 | RodolfoAlvizu | Computer Software Forum - Linux | 20 | 28-Feb-2009 15:23 |
| Flex and bison coding | lucky88star | C++ Forum | 5 | 24-Dec-2007 11:57 |
| Need Help with input files. | Efferus | C++ Forum | 2 | 24-Nov-2007 16:19 |
Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The