Thread: c-program control, conversions

  1. #1
    Registered User
    Join Date
    Sep 2001
    Posts
    13

    Question c-program control, conversions

    I am trying to get this program to convert any num or any letter to its respective equivalent. Thinking of using the "base 2, 10, 8, and 16" and have the program perform the conversion but don't know how. This is as far as i got before getting stuck. this do run but don't do what i want it to do.I guess i may be in deeper then i thought or just don't know what the heck i'm doing yet.
    alittle help please would b greatful.
    thanks
    Glenn



    #include <stdio.h>
    #include <stdlib.h>

    int main()
    {
    int conversion;
    int dDecimal = 0, bBinary = 0, oOctal = 0, hHexadecimal = 0;

    printf("\nEnter what you want converted.\t ");
    printf("Enter KEYBOARD CTRL + Z to end.\n\n ");
    while ( ( conversion = getchar() ) != EOF)

    {
    switch (conversion)
    {
    case 'd': case 'D':
    dDecimal >= 10;
    break;

    case 'b': case 'B':
    bBinary => 11111111;
    break;

    case 'o': case 'O':
    oOctal => 7;
    break;

    case 'h': case 'H':
    hHexadecimal => 9;
    break;

    case '\n': case ' ' :

    break;

    default:
    printf("Your entry cannot be reconized.");
    printf("Please re-enter what you want converted.\n");


    }
    }
    printf("\nThe following is the converted\t");
    printf("equivalent to your entry:\n ");

    printf("\nDecimal equivalent is: %c\n", dDecimal);
    printf("\nBinary equilalent is: %c\n", bBinary);
    printf("\nOctal equivalent is: %c\n", oOctal);
    printf("\nHexadecimal equivalent is: %c\n\n", hHexadecimal);



    system("PAUSE");
    return 0;
    }

  2. #2
    Registered User
    Join Date
    Sep 2001
    Posts
    164
    Why have you putted 'dDecimal >= 10;' and similar in the code? They are removed because they doesn't do anything.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. brace-enclosed error
    By jdc18 in forum C++ Programming
    Replies: 53
    Last Post: 05-03-2007, 05:49 PM
  2. Need help with my program...
    By Noah in forum C Programming
    Replies: 2
    Last Post: 03-11-2006, 07:49 PM
  3. Dikumud
    By maxorator in forum C++ Programming
    Replies: 1
    Last Post: 10-01-2005, 06:39 AM
  4. very weird .h problem
    By royuco77 in forum C++ Programming
    Replies: 1
    Last Post: 09-11-2005, 07:55 AM
  5. My program, anyhelp
    By @licomb in forum C Programming
    Replies: 14
    Last Post: 08-14-2001, 10:04 PM