Monday 27 August 2012

c program Decimal to binary | convert in c

how to convert | decimal  number to binary number in  c language
#include<stdio.h>
#include<conio.h>
#include<math.h>
void main()
{
int a,i=0,n,bin=0,r;
clrscr();
printf("enter the decimal no \n");
scanf("%d",&n);
while(n != 0)
{
r=n%2;
//  a=pow(10,i);
bin=bin+(pow(10,i)*r);
i++;
n=n/2;
}
printf("binary no.=%d \n",bin);
printf("enter the binary no \n");
scanf("%d",&n);
i=0;
bin=0;
while(n != 0)
{
r=n%10;
bin=bin+(pow(2,i)*r);
i++;
n=n/10;
}
printf("decimal no.=%d",bin);

getch();
}
Share This
Previous Post
Next Post

FYJC XI standard online admisson Process and declaraton of Merit list . Cut off List For prevous year also . 10 Th Results onlne declaraton Maharashtra Region .

0 comments: