For example
the binary equivalent of 10 is 1010
The main source code of this program is given below:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include<stdio.h> | |
#include<conio.h> | |
int main() | |
{ | |
int num,i,base=1,sum=0,rem; | |
printf("Enter a number"); | |
scanf("%d",&num); | |
i=num; | |
while(num!=0) | |
{ | |
rem=num%2; | |
sum=sum+rem*base; | |
base=base*10; | |
num=num/2; | |
} | |
printf("the binary equivalent of %d is %d",i,sum); | |
getch(); | |
} |
good solution
ReplyDeleteso can you slove by using function and explane if you
THANKS FOR THE COMMENT. HERE IS YOUR SOURCE CODE.
Deletehttp://ioeengineer.blogspot.com/2014/03/a-program-to-find-binary-equivalent-of.html