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]
]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]
Comment