This program suppose to change a number to binary format.

but somehow it's printing infite 0s.

/* Program that utilizes simple functions to convert decimal numbers */

/* to binary and produces formatted output */

#include <stdlib.h>

#include <stdio.h>

int main(void)

{

/* Declaration */

int m;

int binarynum = 0;

int binarynum2;

/* Ask User to Input numbers */

printf("Enter a number that you want to change in binary format ");

scanf("%d", &m);

/* Print Output for Binaryrep Function */

printf("\n");

printf("The binary format for interger %d is ", m);

/* Call Binaryrep Function */

while (binarynum != EOF)

{

binarynum2 = binaryrep(m);

/* Print result of Binaryrep Function */

printf("%d", binarynum2);

}

return 0;

}

/* Function Power */

int power(int j, int k)

{

/* Declaration */

int num2;

int result = 1;

num2 = k;

if(num2 == 0)

{

result=1;

return result;

}

else

{

for (num2 = 1; num2 <= k; ++num2)

{

result = result * j;

}

return result;

}

}

/* Function Binaryrep */

int binaryrep(int i)

{

int FirstPower = 15;

int num6;

/* Convert interger to binary format */

while (FirstPower >= 0)

{

num6 = power ( 2, FirstPower);

if (num6 <= i)

{

return 1;

i = i - num6;

}

else

{

return 0;

}

FirstPower = FirstPower -1;

}

}