Name: Anonymous 2008-03-18 20:07
Just trying to figure out why this doesn't work, don't tell me to do it "this way", I'm not interested.
//dectohex.c
//17/03/08 16:48
#include <stdio.h>
int main()
{
printf("Input a whole number: ");
int num;
num=getchar();
printf("The decimal number %d converted to hexidecimal is %x!", num, num);
return 0;
}
============
outputs:
C:\hymn-c>dectohex
Input a whole number: 15
The decimal number 49 converted to hexidecimal is 31!
C:\hymn-c>
The only thing I can think of is that getchar() is incompatible with numerical input? I dunno...
//dectohex.c
//17/03/08 16:48
#include <stdio.h>
int main()
{
printf("Input a whole number: ");
int num;
num=getchar();
printf("The decimal number %d converted to hexidecimal is %x!", num, num);
return 0;
}
============
outputs:
C:\hymn-c>dectohex
Input a whole number: 15
The decimal number 49 converted to hexidecimal is 31!
C:\hymn-c>
The only thing I can think of is that getchar() is incompatible with numerical input? I dunno...