The main source code of the above output is:
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 i,num, base=1,sum=0,rem,a; | |
int binary_equivalent(int num); | |
int main() | |
{ | |
printf("enter the decimal no whose binary equivalent is to be found\n"); | |
scanf("%d",&num); | |
a= binary_equivalent(num); | |
printf("the binary equivalent of the above entered decimal no is \n%d",a); | |
getch(); | |
} | |
int binary_equivalent(int num) | |
{ | |
i=num; | |
while(num!=0) | |
{ | |
rem=num%2; | |
sum=sum+rem*base; | |
base=base*10; | |
num=num/2; | |
} | |
return sum; | |
} |
0 comments :
Post a Comment