converting decimal to binary

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • girl23
    New Member
    • Oct 2007
    • 3

    converting decimal to binary

    Hi there
    ]i am new to C programming and totally lost.
    iam trying to convert decimal to binary. here is what i did
    please ignore the case h and m. I am trying to get case 'b' to work.
    i do not want to use cout and cin. is there any other way to change the last function. please someone help me.

    [CODE=c]#include <stdio.h>
    #include <time.h>

    int main( )
    {
    char cmd = '.', tmp, tmp2;
    int counter = 0;
    int number = 0;

    printf( "Converter Program v1.0\n" );

    do
    {
    printf( "(q for quit, h for help)\n> " );
    scanf( "%c%c", &cmd, &tmp );
    // printMenu( ); //prototype for printMenu()
    // Monthname( number );
    void binary ( number );

    switch( cmd )
    {
    /* case 'h':
    printMenu( ); // calling the function printMenu
    break;
    case 'm':
    printf( "What month? Enter a number between 1 and 12: " );
    scanf( "%d%c", &number, &tmp );
    Monthname( number );
    break;*/
    case 'b':
    printf( "What decimal number would you like converted to binary? " );
    scanf( "%d%c", &number, &tmp2 );
    printf( "%d in binary is: ", number );
    void binary( int number );

    break;
    }
    } while( cmd != 'q' );
    printf( "Good Bye!\n" );
    return 0;
    }

    void binary( int number )
    {
    int remainder;

    if(number <= 1)
    {
    number; // i know this is wrong. is there any other way besides cout

    }

    remainder = number%2;
    binary(number >> 1);
    remainder;
    }[/CODE]
    Last edited by Ganon11; Oct 17 '07, 03:40 AM. Reason: Please use the [CODE] tags provided.
  • rhitam30111985
    New Member
    • Aug 2007
    • 112

    #2
    rhitam-

    I know we've asked you not to spoonfeed already. Please provide details on how the OP can change their code.
    Last edited by rhitam30111985; Oct 17 '07, 05:09 AM. Reason: added code tags

    Comment

    Working...