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 do you convert strings to numbers in C?
What is a volatile keyword in c?
What does calloc stand for?
1) write a program to generate 1st n fibonacci prime numbers using Nested if 2) write a program to generate twin prime numbers from m to n using nested if 3) write a program to check whether a given integer is a strong number or not using nested if 4) Write a program to generate prime factors of a given integer using nested if 5)write a program to generate prime numbers from m to n using nested if 6)write a program to generate perfect numbers from m to n using nested if 7)write a program to generate the pallindromes from m to n using neste if 8)write a program to generate armstrong numbers from m to n using nested if 9)write a program to generate strong numbers from m to n using nested if
what are the advanced features of functions a) function declaration and prototypes b) calling functions by value or by reference c) recursion d) all the above
Is file a keyword in c?
What is floating point constants?
I completed my B.tech (IT). Actually I want to develop virtual object that which will change software technology in the future. To develop virtual object what course I have to take. can I any professor to help me.
write a program to display all prime numbers
What is meant by 'bit masking'?
What does main () mean in c?
Why we use void main in c?
Explain what is the difference between text files and binary files?
What is ## preprocessor operator in c?
typedef enum { html, java, javascript, perl, cgi } lang;The above statement defines a : a) Union b) User defined type c) Enumerated variable d) none