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 size of empty structure in c?
What are data structures in c and how to use them?
Explain what is the difference between a string and an array?
Can we change the value of #define in c?
Explain what happens if you free a pointer twice?
Explain what is dynamic data structure?
What are pointers in C? Give an example where to illustrate their significance.
What is the use of sizeof?
Explain what are the standard predefined macros?
What is linear search?
What is a dynamic array in c?
Why is a semicolon (;) put at the end of every program statement?
What is LINKED LIST? How can you access the last element in a linked list?
WHICH TYPE OF JOBS WE GET BY WRITING GROUPS .WHEN THE EXAMS CONDUCTED IS THIS EXAMS ARE CONDUCTED EVERY YEAR OR NOT.PLS TELL ME THE ANSWER
hi send me sample aptitude papers of cts?