U have not learnt function yet ?
I can help u to learn function, if u give me your email id.
This program can also be solved without using function.
but here m using two loops one for counting digits int binary number and other
for converting to decimal.
here is the solution.
//Program to convert a binary number to its equivalent decimal number
#include<stdio.h>
#include<conio.h>
#include<math.h>
int main()
{
int count_digits(int);
int num,num1,n=0,R,r,dec=0;
clrscr();
printf("\nEnter a number in binary form : ");
scanf("%d",&num);
num1=num;
while(num1) //loop for counting the digits
{
num1/=10;
n++;
}
while(num) //loop for converting the binary number into decimal
{
r=num%10;
R=r*pow(2,--n);
dec+=R;
num=num/10;
}
printf("\nDecimal : %d", dec);
getch();
return 0;
}