Code -
//__Program to convert Decimal number into Binary number Version 1___
/* Best works for number less than 999 */
//___________Including header files_____________
#include<stdio.h>
#include<conio.h>
int main()
{
int decimal_number = 0, remainder = 0, temp_number = 0, binary_number = 0, counter = 1;
printf("\n\n\t__ Program to convert Decimal number into Binary number __ ");
printf("\n\n\n Enter the Decimal Number - ");
scanf("%d",&decimal_number);
temp_number = decimal_number;
while(temp_number != 0)
{
remainder = temp_number % 2;
temp_number = temp_number / 2;
binary_number = binary_number + remainder * counter ;
counter = counter * 10;
}
printf("\n\n\t Binary equivalent of Decimal number - %d is %d",decimal_number, binary_number);
getch();
return 0;
}
Follow Us on Facebook - Assignment Hub
No comments:
Post a Comment