Write a program in C to Convert Decimal to Binary number.
#include<stdio.h> #include<conio.h> main() { long long int bin=0,dec,base=1; clrscr(); printf("Enter a number:-"); scanf("%lld",&dec); while(dec!=0) { bin=dec%2*base+bin; base=base*10; dec=dec/2; } printf("\nBinary equivalent=%lld",bin); getch(); }
Output:-
0 Comments