If you are using any software then below program will not give an error, but if you are using **TURBO C** then you have to make some changes like: void main() and some function like clrscr() or getch().

#include<stdio.h> main() { int n,n1,c; int decimal_to_binary(int); //Accepting decimal number printf("Enter any decimal number\n"); scanf("%d",&n); c=decimal_to_binary(n); printf("Decimal to binary of %d is %d",n,c); } //Converting to binary number int decimal_to_binary(int n) { int rem,bin=0,i=1; while(n) { rem=n%2; bin=bin+(rem*i); n=n/2; i=i*10; } return(bin); }

OUTPUT:

Enter any decimal number 5 Decimal to binary of 5 is 101 Enter any decimal number 8 Decimal to binary of 8 is 1000