Day#60 'C' Coding Challenge (Write a code to convert Decimal to Binary)

Day#60 'C' Coding Challenge (Write a code to convert Decimal to Binary)

Write a code to convert Decimal to Binary

#include<stdio.h>
#include<math.h>

void main()
{
int number = 25;
int binary = 0;
int count = 1;
int Mod = 0;
while(number != 0)
{
Mod = number % 2;
number = number/2;
binary = binary + Mod*count;
count = count*10;
}
printf("%d",binary);
}

Post a Comment

0 Comments