Decimal to Binary Conversion



Sumit Kar, Sorting, C, Timus Rak, C Program



#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("Equivalent binary value of decimal number %d: ",decimalNumber);
for(j = i -1 ;j> 0;j--)
printf("%d",binaryNumber[j]);

return 0;
}

/*
Summary: Converts decimal number which is base 10 number system 0-9 to binary which is base 2 number system 0 and 1.
*/


Comments

Popular posts from this blog

Write a Program to Add two 3x3 Matrix using C

C program for Unit Conversion

Write a Program to Add two 5x5 Matrix using C