I need to write a program that will ask the user for a base 10 number in the range 1 to 4,000,000,000. Then display the number in every number base from 2 to 36 on one screen.
I know i need to write a function that you send the number and the base, and it prints the converted representation.
I also know my function should use the repeated division/remainder algorithm to convert the number. I'll keep the remainders in an array until complete, then print the corresponding digits in reverse order (since the last remainder represents the first digit).
I just am totally lost on how to start this...
I only know the C++ language so if you can help me out in this language only, that would be great
Any help would be amazing. Thanks!
Comp programming C++ converting to diff base?
int conv (int base, long no, char* str)
{
if(no==0) strcpy(str,"0");
int count = 0;
char ct[256] = "";
char* ult = ch;
do{
*ult = no%base;
ult++;
no= no/base
}while(no%26gt;=0);
strcpy(ultt,_strrev(ult));
strcpy(str,ult);
}
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment