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
How was c created?
How can I call fortran?
What is action and transformation in spark?
If one class contains another class as a member, in what order are the two class constructors called a) Constructor for the member class is called first b) Constructor for the member class is called second c) Only one of the constructors is called d) all of the above
What is double pointer in c?
What is the symbol indicated the c-preprocessor?
Dont ansi function prototypes render lint obsolete?
can anyone suggest some site name..where i can get some good data structure puzzles???
What is a void pointer in c?
How do you declare a variable that will hold string values?
Tell me when is a void pointer used?
Here is a neat trick for checking whether two strings are equal
Difference between MAC vs. IP Addressing
write a program to create a sparse matrix using dynamic memory allocation.
Difference between Function to pointer and pointer to function