0

Hi. I'm trying to call a function to convert a decimal integer into a binary number (stored as an array of integers). Before I knew that I couldn't return an array, this is how I thought to implement it. Can anyone help me understand the way I'm actually supposed to do this?

Thank you very much.

Here is MAIN:

```
#include <stdio.h>
#include <math.h>
int dec2bin (int decimal);
int main(void) {
int binary[8]; // creates array to store 8-bit binary number
int decimal=5; // with a test value. final version will have user input.
binary = dec2bin(decimal);
```

And my function:

```
int dec2bin (int decimal) {
int binary[8];
int x;
for (x=8; x>0; x--) {
binary[x] = decimal % 2;
decimal /= 2;
printf("%d", binary[x]);
}
return binary;
}
```