alright.. been workin on this silly little program.. it's a numeric conversion program... here is what it needs to look like .. and i have to include while, if, and else if statements in it...
2. The program should prompt the user as shown below:
---------------------------------------------------------------------
NUMERIC CONVERSION PROGRAM
---------------------------------------------------------------------
3. Enter Base of Input (d=decimal, o=octal, h=hexadecimal): d
4. Enter Input Number: 178
5. Enter Base of Output (d=decimal, o=octal, h=hexadecimal): h
6. The integer 178 in decimal is equivalent to B2 in hexadecimal
---------------------------------------------------------------------------------
and this is the pathetic crap i have so far... because i don't understand the if, while, and else if staments yet.. so any help would be greatly appreciated.. thank you in advance..
---------------------------------------------------------------------------------
//
#include
int main (void)
{
int d, o, h, x;
char base;
long int D;
long int O;
long int H;
printf("-----------------------------------------------------------------\n");
printf(" NUMERIC CONVERSION PROGRAM \n");
printf("-----------------------------------------------------------------\n");
printf("Enter Base of Input (d=decimal, o=octal, h=hexadecimal) : ");
scanf("%c", &base);
printf("Enter input number : ");
scanf("%d", &D, &O, &H);
printf("Enter Base of Output (d=decimal, o=octal, h=hexadecimal) : ");
scanf("%d", &D, &O, &H);
if (base = h)
printf("then your integer %d will be %h in hexadecimal:\n",D, D);
return 0;
if (base = o)
printf("then your integer %d will be %o in octal:\n",D, D);
return 0;
if (base = d)
printf("then your integer %d will be %d in decimal:\n",D, D);
return 0;
}
//
alright... i kinda started over, and am now only trying to get the program to return 1 type of conversion..... and i cannot get it to.. please help.. please tell me how far off i am.. lol
/*
#include <stdio.h>
void main()
{
int D,O,H;
int num;
int d,o,h;
char base;
char base_out;
printf("------------------------------------------------------\n");
printf(" NUMERIC CONVERSION PROGRAM\n");
printf("------------------------------------------------------\n");
printf("Enter Base of Input (d=decimal, o=octal, h=hexadecimal) : ");
scanf("%s", &base);
printf("Enter input number : ");
scanf("%d", &num);
printf("Enter Base of Output (d=decimal, o=octal, h=hexadecimal) : ");
scanf("%s", &base_out);
if(base == d)
{
printf("then you integer %s would equal %d in decimal\n",base,base_out);
}
}
*/