C Program to Convert Decimal to Binary

#include <stdio.h>

#include <math.h>

long long convertdecimaltobinary(int);

int main()

{

    int decimal, binary;

    printf("Enter a decimal number\n ");

    scanf("%d", &decimal);

    binary = convertdecimaltobinary(decimal);

    printf("%d in decimal =  %lld in binary", decimal, binary);

    return 0;

}

long long convertdecimaltobinary(int decimal)

{

    long long binary = 0;

    int reminder, i = 1;

    while (decimal != 0)

    {

        reminder = decimal % 2;

        decimal /= 2;

        binary += reminder * i;

        i *= 10;

    }

    return binary;

}