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
What are the ways to a null pointer can use in c programming language?
What are the types of macro formats?
What is getch?
What is the right type to use for boolean values in c? Is there a standard type? Should I use #defines or enums for the true and false values?
What are the 5 organizational structures?
Is exit(status) truly equivalent to returning the same status from main?
Explain what are multibyte characters?
How are strings stored in c?
any restrictions have on the number of 'return' statements that may be present in a function. a) no restriction b) only 2 return statements c) only 1 return statements d) none of the above
Write a program to check whether a number is prime or not using c?
Who invented bcpl language?
What is 1d array in c?
Explain what is the difference between functions abs() and fabs()?
What is the difference between malloc() and calloc() function in c language?
How pointer is different from array?