adsense

Hii, welcome to my site. My name is Om prakash kartik. This blog helps you to learn programming languages concepts.

Write a program in C to Convert Decimal to Binary number.

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:-

          

Post a Comment

0 Comments