Ans:->
The program to convert positive integer number to its binary equivalent in C Language
Program is as follows:--
#include <stdio.h>
#include <math.h>
long decimalToBinary(int decimalnum)
{
long binarynum = 0;
int rem, temp = 1;
while (decimalnum!=0)
{
rem = decimalnum%2;
decimalnum = decimalnum / 2;
binarynum = binarynum + rem*temp;
temp = temp * 10;
}
return binarynum;
}
int main()
{
int decimalnum;
printf("Enter a Decimal Number: ");
scanf("%d", &decimalnum);
printf("Equivalent Binary Number is: %ld", decimalToBinary(decimalnum));
return 0;
}
OUTPUT:---
Enter a Decimal Number: 56
Equivalent Binary Number is: 111000
Do You Know the answer for this question:-
Click on the Link for the Answer 👇👇
1 Comments
Great share!! Thanks for sharing this code much helpful 🙂
ReplyDeleteIf you want to give any suggestion regarding the post please feel free to Comment below-