Decimal to Binary Conversion Logic in C program
This is program which is gives you output as Binary of any Integer. Program Store the binary output as Integer just for reference. We can use it further where required. Decimal to binary needs Math.h Library file to use power function./* Program For Decimal to Binary Conversions*/ #include<stdio.h> #include<math.h> int main() { int no,rem; printf("\nEnter no\n"); scanf("%d",&no); int bs=no; int sum=0; int pw=0; while(no) { rem=no%2; sum=sum+rem*(pow(10,pw)); no=no/2; pw++; } printf("Decimal to Binary of this no %d \t :%d\n",bs,sum); return 0; }
0 comments:
Post a Comment