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
Is it possible to use curly brackets ({}) to enclose single line code in c program?
How can you access memory located at a certain address?
write a program in c language to print your bio-data on the screen by using functions.
How can a process change an environment variable in its caller?
Why void is used in c?
Explain how does flowchart help in writing a program?
What are void pointers in c?
how much salary u want ? why u join in our company? your domain is core sector why u prefer software ?
What is nested structure?
What is ambagious result in C? explain with an example.
Can we declare a function inside a function in c?
What is an operator?
can anyone please tell about the nested interrupts?
When is a null pointer used?
why do some people write if(0 == x) instead of if(x == 0)?