Program in c to convert decimal no. into corresponding binary number


Program in c to convert decimal no. into corresponding binary number
#include<stdio.h>
#include<conio.h>
void main()
 {
  int dec,d,c=1;
  long int bn=0;
  clrscr();
  printf("Enter decimal number:");
  scanf("%d",&dec);
  while(dec!=0)
   {
    d=dec%2;
    dec=dec/2;
    bn=bn+c*d;
    c=c*10;
   }
  printf("Binary no. of given decimal no. is:");
   printf("%ld",bn);
  getch();
 }
output:
enter decimal number: 7
Binary no. of given decimal no. is:111

Comments

Popular posts from this blog

C Program to implement GAUSS' FORWARD INTERPOLATION FORMULA

c Program to implement GAUSS' BACKWARD INTERPOLATION FORMULA

Program to implement BESSELS INTERPOLATION FORMULA in C