How to convert decimal to binary in C using recursion??
Answer Posted / rajaas tahir
# include <stdio.h>
#include<conio.h>
void Bin (int num);
int main (void)
{
int num;
int base;
printf ("Enter the decimal number to convert it binary.\n");
scanf ("%d", &num);
printf ("The %d in binary is : ", num);
Bin (num);
getch();
}
void Bin (int num)
{
int a, b;
a=num/2;
if ((a!= 0) && (num > 1))
{
printf("%d",(num%2));
Bin (num / 2);
}
}
| Is This Answer Correct ? | 3 Yes | 14 No |
Post New Answer View All Answers
Tell us two differences between new () and malloc ()?
What is the use of define in c?
"C" language developed by "Dennis Ritchie" at AT & T. his remarks are a) too general, too abstract b) could deal with only specific problems c) lost generality of BCPL and B restored d) no remarks
Which is an example of a structural homology?
What is page thrashing?
Given below are three different ways to print the character for ASCII code 88. Which is the correct way1) char c = 88; cout << c << " ";2) cout.put(88);3) cout << char(88) << " "; a) 1 b) 2 c) 3 d) constant
Should I use symbolic names like true and false for boolean constants, or plain 1 and 0?
Explain the use of bit fieild.
How do I convert a string to all upper or lower case?
What is array of pointers to string?
What is #include called?
What is the purpose of 'register' keyword?
What is class and object in c?
How can I manipulate strings of multibyte characters?
What is structure packing in c?