Decimal To Binary Conversion in C
#include<stdio.h>
int main()
{
long int decimalNumber,remainder,quotient;
int binaryNumber[100],i=1,j;
printf("Enter any decimal number: ");
scanf("%ld",&decimalNumber);
quotient = decimalNumber;
while(quotient!=0)
{
binaryNumber[i++]= quotient % 2;
quotient = quotient / 2;
}
printf("\nEquivalent binary value of decimal number %d: ",decimalNumber);
for(j=i-1;j>0;j--)
printf("%d",binaryNumber[j]);
printf("\n");
}
#include<stdio.h>
int main()
{
long int decimalNumber,remainder,quotient;
int binaryNumber[100],i=1,j;
printf("Enter any decimal number: ");
scanf("%ld",&decimalNumber);
quotient = decimalNumber;
while(quotient!=0)
{
binaryNumber[i++]= quotient % 2;
quotient = quotient / 2;
}
printf("\nEquivalent binary value of decimal number %d: ",decimalNumber);
for(j=i-1;j>0;j--)
printf("%d",binaryNumber[j]);
printf("\n");
}
No comments:
Post a Comment