Computer Science, asked by averagestudent99, 3 days ago

write an algorithm, draw a flowchart and develop a c program to convert decimal number to its equivalent binary number

please help, thanks.

Answers

Answered by utsavsinghal
0

Answer:

#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: 234 Equivalent Binary Number is: 11101010

Similar questions