C program to convert a number from binary to decimal format using function

C program to convert a number from binary to decimal format using function

Write a C program to convert a number from binary to decimal format using a function. 
Hi, if your question is about writing a program in c to convert decimal numbers to binary numbers using the function here in the program. this program is for writing a c program to convert decimals to the binary number system. Our program decimal to binary in c without using an array.


#include 
int conv(long long n);
int main()
{
?long long n;
?printf("Enter a binary number: ");
?scanf("%lld", &n);
?printf("%lld in binary = %d in decimal", n, conv(n));
?return 0;
}
int conv(long long n)
{
?int dec = 0, i = 0, rem;
?while (n != 0)
?{
?rem = n % 10;
?n /= 10;
?dec += rem * pow(2, i);
?++i;
?}
?return dec;
}