/* C Program To Convert Decimal Number Into Binary Number */ #include<stdio.h> #include<conio.h> #include<math.h> int main() { int n,rem, i=1, binary=0,m; printf("Enter a decimal number:\n"); scanf("%d", &n); m=n; while (n!=0) { rem=n%2; n/=2; binary+=rem*i; i*=10; } printf("Binary equivalent of %d is: %d", m, binary); return 0; }
Enter a decimal number: 37 Binary equivalent of 37 is: 100101
No comments:
Post a Comment