How to convert decimal to binary in C using recursion??
Answer Posted / sd
#include<stdio.h>
int bin(int);
main()
{ int n,r;
printf("Enter the number in decimal:");
scanf("%d",&n);
r=bin(n);
printf("The binary equivalent is:%d",r);
getch();
}
int bin(int x)
{ int k;
if(x==0)
return 0;
k=x%2;
int j=k+(10*bin(x/2));
return j;
}
| Is This Answer Correct ? | 3 Yes | 3 No |
Post New Answer View All Answers
What is the condition that is applied with ?: Operator?
Tell me when would you use a pointer to a function?
Can you please explain the difference between malloc() and calloc() function?
Why is sizeof () an operator and not a function?
What is boolean in c?
What is difference between scanf and gets?
hi send me sample aptitude papers of cts?
Can we initialize extern variable in c?
What do you mean by dynamic memory allocation in c?
A collection of functions,calls,subroutines or other data a) library b) header files c) set of files d) textfiles
What is the c language function prototype?
Why is c so important?
Why double pointer is used in c?
about c language
What are different types of pointers?