# Thread: school project been killin me..

1. ## school project been killin me..

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)
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);
}

}
*/

2. >>if (base = h)
You're assigning for base the value of H, you need to use the == operator and not just = so, the correct is if (base == h);

>>if (base = o)
printf("then your integer %d will be %o in octal:\n",D, D);
return 0;

Again, use ==. When you want to execute a block, and not just a line of code, like in this case, you have to use bracets like here
Code:
```if (base == o) {
printf("then your integer %d will be %o in octal:\n",D, D);
return 0;
}```
I don't get your idea here:
Code:
```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);```
>>scanf("%d", &D, &O, &H);
this is wrong, what you're trying to do? assign to these 3 variables the value of the input? if yes, try something like that:
Code:
```scanf("%ld",&D);
O = H = D;```
Also use code tags when posting in the forum, ahh welcome