hi i am making a Bcd to Binary conversion can somebody help me lessen the code? thanks.

//! Converts a two-byte, 3-digit, BCD number into a binary value.
extern uint16_t BcdBin( const uint8_t* const pBcdBin);

//uint16_t BcdBin(const uint8_t * const pBcdBin)

int main()
{
int Num;
int A=0,B=0,C,D,E=1;
int F[100];



printf("Enter the number :");
scanf("%d",&Num);


while(Num>0)

{

A=Num%2;

F[B]=A;

Num=Num/2;

B++;

}

if(B<4)

{
       C=B;

for(D=1;D<=4-C;D++)

{

F[B]=0;

B++;
}
}

if(B>4)

{

for(D=0;D<B;D++)

{ if(E==4)

E=1;
else

E++;
}
E--;
if(E<4)
{ for(D=1;D<=4-E;D++)

{
F[B]=0;

B++;

}
}

}

for(E=1,D=B-1;D>=0;D--,E++)

{ printf("%d",F[D]);

if(E==4)

{ printf(" ");

E=0;
}

}

getch();

}

Start with formatting.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.