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 pass by value in c?
What is the purpose of main( ) in c language?
What is the best organizational structure?
List the different types of c tokens?
What is a structure and why it is used?
Is null equal to 0 in sql?
How can you access memory located at a certain address?
we need to calculating INCOME TAX for the person. The INCOME TAX is as follows:- First $10000/- of income : 4% tax Next $10000/- of income : 8% tax Next $10000/- of income : 11.5% tax above $10, 00,00/- : 15% tax What is the Solution of this Question ?
How does struct work in c?
In a switch statement, what will happen if a break statement is omitted?
What is scope of variable in c?
pgm to find any error in linklist(in single linklist check whether any node points any of previous nodes instead of next node)
Explain modulus operator. What are the restrictions of a modulus operator?
What are control structures? What are the different types?
Is boolean a datatype in c?