How to convert decimal to binary in C using recursion??
Answer Posted / jaguar
Please check the following program buddy,
Just save it as .c and run it you got what you want
# include <stdio.h>
void Rec_Dec_To_Bin (int num);
void main ()
{
int num;
int base;
printf ("Enter the decimal number to convert it binary.\n");
scanf ("%d", &num);
printf ("The number in decimal is : %d\n", num);
printf ("\n");
printf ("The %d in binary is : ", num);
Rec_Dec_To_Bin (num);
printf ("\n\n");
}
void Rec_Dec_To_Bin (int num)
{
if (((num / 2) != 0) && (num > 1))
{
Rec_Dec_To_Bin ((num / 2));
}
printf ("%d", (num % 2));
}
| Is This Answer Correct ? | 21 Yes | 17 No |
Post New Answer View All Answers
What is the difference between pure virtual function and virtual function?
main() { inta=10,b=20; a>=5?b=100:b=200; printf("%d ",b); }
What is substring in c?
Why header file is used in c?
How many levels of pointers can you have?
What is the total generic pointer type?
I have seen function declarations that look like this
How do you sort filenames in a directory?
What is chain pointer in c?
Which node is more powerful and can handle local information processing or graphics processing?
What header files do I need in order to define the standard library functions I use?
What are the types of arrays in c?
What are the 4 types of programming language?
Is c dynamically typed?
What is pointer to pointer in c language?