Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!


do you know a number system conversion code in C?

we need a code in C that converts binary to octal, decimal to hexadecimal and octal to hexadecimal.. :)


  • mcsuper5mcsuper5 Member Posts: 9

    int main(int argc, char **argv) {
    int n;
    char binary[255];
    int i;

    printf("Enter a number? ");
    scanf("%i", &n);
    printf("%d 0%o 0x%X
    ", n, n, n);

    Enter Binary number");
    scanf("%s", binary);
    for (n=0, i=0; i<strlen(binary); i++) {
    n = n*2+(binary[i]-'0');
    printf("%s %d, 0%o, 0x%X
    ", binary, n, n, n);

    return 0;

  • mcsuper5mcsuper5 Member Posts: 9
    This post has been deleted.
Sign In or Register to comment.