|
||||||
| C and C++ C and C++ forum for discussing all forms of C except for C#. These languages are powerful low level languages used for creating Operating Systems, Device Drivers, compilers and much more. |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
|
|||
|
ok, heres my code
#include <iostream> #include <iomanip> #include <cmath> using namespace std; void convert (int num1, int base1) { int remainder; remainder = num1 % base1; if (num1 / base1 == 0) { if (remainder <= 9) cout << remainder; else if (remainder > 10) { cout << static_cast <char> (remainder + 55); } } else { num1 /= base1; convert (num1, base1); } } int main() { int base; int num; cout << "Please enter the base: "; cin >> base; cout << "Please enter the number: "; cin >> num; cout << "The converted number is "; convert(num, base); cout << endl; system ("pause"); return 0; } what i am trying to do here is when i send in two numbers, a base and a number, i am trying to convert it into a new output like this i send in my base 16 and my number by 575 i should get something like 3F but i always get 2 does anybody have any ideas? |
| Sponsored Links |
|
|
|
|||||
|
Out of curiosity, why are you doing this with recursion instead of using a while loop?
__________________
CodeCall Blog | CodeCall Wiki | Shareware | Linux Forum Chat with other CodeCall members on IRC; connect to irc.codecall.net and join #codecall |
![]() |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | Search this Thread |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Peculiar UI Problem Needs Tackling | adriyel | C# Programming | 2 | 04-06-2008 07:46 AM |
| i have a problem please help me!!!???? | stack | Java Help | 8 | 09-22-2007 03:17 PM |
| [C] Comparison problem | Alhazred | C and C++ | 1 | 08-29-2007 04:58 AM |
| null exception problem | connor7777 | C# Programming | 2 | 03-28-2007 11:37 AM |
| A small problem in the output | The_Master | C and C++ | 3 | 12-13-2006 12:04 PM |
| Xav | ........ | 1322.18 |
| MeTh0Dz|Reb0rn | ........ | 1053.7 |
| morefood2001 | ........ | 879.43 |
| John | ........ | 877.37 |
| marwex89 | ........ | 869.98 |
| WingedPanther | ........ | 830.24 |
| Brandon W | ........ | 735.07 |
| chili5 | ........ | 309.39 |
| Steve.L | ........ | 236.23 |
| dcs | ........ | 216.02 |
Goal: 100,000 Posts
Complete: 82%