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


Please Help Members By Posting Answers For Below Questions

Can we change the value of #define in c?

584


What is volatile keyword in c?

583


can any one tel me wt is the question pattern for NIC exam

1558


how to print electricity bill according to following charges first 100 units -1rs per unit for next 200 units-1.50 rs per unit without using conditions

2722


What is the difference between functions abs() and fabs()?

649






‘SAVEPOINT’ and ‘ROLLBACK’ is used in oracle database to secure the data comment. Give suitable examples of each with sql command.

1879


What are dangling pointers in c?

639


What is a pointer variable in c language?

643


What do you mean by recursion in c?

626


in multiple branching construct "default" case is a) optional b) compulsarily c) it is not include in this construct d) none of the above

635


Function which gives a pointer to a binary trees const an integer value at each code, return function of all the nodes in binary tree.?

628


Explain how can you tell whether two strings are the same?

580


Describe the steps to insert data into a singly linked list.

622


If the size of int data type is two bytes, what is the range of signed int data type?

592


Explain what is #line used for?

608