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 are 16- and 32-bit numbers stored?
What are the types of type specifiers?
Explain built-in function?
An organised method of depicting the use of an area of computer memory used to signify the uses for different parts of the memory a) swap b) extended memory c) memory map d) all of the above
Differentiate between a structure and a union.
What is assignment operator?
how do you write a function that takes a variable number of arguments? What is the prototype of printf () function?
Does c have an equivalent to pascals with statement?
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
Explain what is the benefit of using #define to declare a constant?
#include main() { enum _tag{ left=10, right, front=100, back}; printf("left is %d, right is %d, front is %d, back is %d",left,right,front,back); }
Is fortran still used in 2018?
if (i = 0)printf ("True"); elseprintf("False"); Under what conditions will the above print out the string "True" a) Never b) Always c) When the value of i is 0 d) all of the above
Is register a keyword in c?
What is %s and %d in c?