Sunday, December 9, 2012

WAP to print Decimal to Binary 25


#include<stdio.h>
#include<conio.h>
void main()
{
long int no,rem=0,base=1,number=0,i;
clrscr();

printf("enter yhr number:");
scanf("%d",&no);

while(no!=0)
{
     rem=no%2;
     no=no/2;
     base=base*10;
     number+=rem*base;
     i++;

}
printf("%ld",number);
getch();
}

No comments:

Post a Comment