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 a protocol in c?
the 'sizeof' operator reported a larger size than the calculated size for a structure type. What could be the reason?
How to declare pointer variables?
How will you declare an array of three function pointers where each function receives two ints and returns a float?
In c programming language, how many parameters can be passed to a function ?
What is modifier & how many types of modifiers available in c?
What is the purpose of the following code? Is there any problem with the code? void send(int count, short *to, short *from) { /* count > 0 assumed */ register n = (count + 7) / 8; switch (count % 8) { case 0: do { *to = *from++; case 7: *to = *from++; case 6: *to = *from++; case 5: *to = *from++; case 4: *to = *from++; case 3: *to = *from++; case 2: *to = *from++; case 1: *to = *from++; } while (--n > 0); } }
How do you do dynamic memory allocation in C applications?
What is Dynamic memory allocation in C? Name the dynamic allocation functions.
What is an array? What the different types of arrays in c?
Write a function expand(s1,s2) that expands shorthand notations like a-z in the string s1 into the equivalent complete list abc...xyz in s2 . Allow for letters of either case and digits, and be prepared to handle cases like a-b-c and a-z0-9 and -a-z. z-a:zyx......ba -1-6-:-123456- 1-9-1:123456789987654321 a-R-L:a-R...L a-b-c:abbc
How do you convert a decimal number to its hexa-decimal equivalent.Give a C code to do the same
What is the difference between memcpy and memmove?
Which is not valid in C a) class aClass{public:int x;}; b) /* A comment */ c) char x=12;
Describe the header file and its usage in c programming?