#include <stdio.h>

#include<conio.h>

void main()

{

long num, decimal, rem, base = 1, binary = 0;

clrscr();

printf(“Enter a decimal integer \n”);

scanf(“%ld”, &num);

decimal = num;

while (num > 0)

{

rem = num % 2;

binary = binary + rem * base;

num = num / 2;

base = base * 10;

}

printf(“Decimal number is = %d\n”, decimal);

printf(“Binary equivalent is = %ld\n”, binary);

getch();

}

Output:-

Advertisements