WELL IT IS HERE IS ANOTHER PROGRAM FOR THE CONVERSION FROM DECIMAL TO BINARY.I HAVE USED A RECURSIVE FUNCTION . ENJOY
REGARDS,
NABEEL
#include<stdio.h>
#include<conio.h>
#include<math.h>
void dec(int);
void main()
{
clrscr();
int num=0;
printf("ENTER A DECIMAL NUMBER :\t");
scanf("%d",&num);
printf("THE BINARY EQUIVALENT OF %d IS ",num);
dec(num);
getch();
}
void dec(int num)
{
int remainder;
if(num==1)
printf("%d",num);
else
{
remainder=num%2;
num=num/2;
dec(num);
printf("%d",remainder);
}
}
No comments:
Post a Comment