Saturday, May 22, 2010

Help with C, function/binary?

I would really appreciate this, since i dont understand how functions work and the pointing by reference - i need to make a function that will convert from decimal/integer to binary and possibly 2's compliment then i need to know how to add them up. Could anyone be so kind to show me how to do this? thank you very much!! i included a shell that im supposed to use for this.





#include %26lt;stdio.h%26gt;


#include %26lt;math.h%26gt;


#define BITS 8





void convertBinary(int, int*);


void convert2sComp(int*);





int main() {


}





void convertBinary(int decimal, int *binNumber)


{


}





void convert2sComp(int *binNumber)


{


}

Help with C, function/binary?
HMMM... do you perhaps go to UofL speed school and currently have CECS 230? if so, i would advise you to get help from someone in your class because if you are struggling on a program like this, this early in the semester, it does not look like you are going to be finishing school with a very good grade
Reply:This doesn't make sense. The C compiler will already have converted any numbers in your program to a binary representation during compilation. So for example the convertBinary function is a copy like this:





void convertBinary(int decimal, int *binNumber)


{


*binNumber = decimal;


}





Are the decimal numbers held in strings? Read the exercise questions again.


No comments:

Post a Comment