- November 3, 2007 at 5:54 am #2024kenezParticipant
Guys I need to write a program that will convert FROM and TO any bases ranging from 2 to 10.oh bases meaning binary, base 3 numbers, octal etc(up to 10)
The program should prompt for the base “converted to” and the base “converted from”.
Can somebody tell me how I need to go about this and what aspects of C
maybe helpful. I will do the actual coding and report any problems.
- March 13, 2008 at 11:24 pm #3264yeswanthParticipant
A program to convert a decimal number to its equivalent binary number.
unsigned long dec;
printf("nENTER A DECIMAL NUMBER: ");
printf("n%lu IN BINARY FORMAT: ",dec);
- April 28, 2008 at 1:23 pm #3265Priyansh AgrawalParticipant
This code could do this from base 2-10 to base 2-10. There is a nice function called itoa that converts int to char* and you can specify the base. Unfortunatelly the function atoi has no base-parameter. So I recoded it:
int xy(int x,int y)
int my_atoi(char *s,int base)
for (j=0;j<80 && s[j]!=0 && s[j]>='0' && s[j]<='9';j++);
printf(" to base:");
printf("nresult is %sn",buff);
- The forum ‘C Programming’ is closed to new topics and replies.