:: Home Page            
 Advertise your Business Here     
Browse  |   Placement Papers  |   Company  |   Code Snippets  |   Certifications  |   Visa Questions
Post Question  |   Post Answer  |   My Panel  |   Search  |   Articles  |   Topics  |   ERRORS new
   Refer this Site  Refer This Site to Your Friends  Site Map  Bookmark this Site  Set it as your HomePage  Contact Us     Login  |  Sign Up                      
Categories >> Software >> Programming Languages >> C


 C interview questions  C Interview Questions (2266)
 C++ interview questions  C++ Interview Questions (1121)
 VC++ interview questions  VC++ Interview Questions (342)
 Delphi interview questions  Delphi Interview Questions (510)
 Programming Languages AllOther interview questions  Programming Languages AllOther Interview Questions (652)
How to convert decimal to binary in C using recursion??
 Question Submitted By :: C
I also faced this Question!!     Answer Posted By  
# 1
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 15 No
# 2
int bin(int);
{ int n,r;
printf("Enter the number in decimal:");
printf("The binary equivalent is:%d",r);
int bin(int x)
{ int k;
return 0;
int j=k+(10*bin(x/2));
return j;
Is This Answer Correct ?    2 Yes 1 No
# 3
# include <stdio.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);

void Bin (int num)

int a, b;
if ((a!= 0) && (num > 1))
Bin (num / 2);

Is This Answer Correct ?    3 Yes 12 No
Rajaas Tahir
# 4
by dividing that number by 2.. 
Is This Answer Correct ?    4 Yes 14 No

Other C Interview Questions
  Question Asked @ Answers
consider the following program sigment int n,sum=1; switch(n) { case 2:sum=sum+2; case 3:sum*=2; break; default:sum=0;} if n=2, what is the value of sum a.0 b.6 c.3 d.none TCS 7
How do I initialize a pointer to a function?   2
How can I allocate arrays or structures bigger than 64K?   5
related proverb of "dont count your chicken before it hatches"   1
why arithmetic operation canít be performed on a void pointer?   1
program for validity of triangle from 3 side   7
Efficient data structure for store/search list of 1000 records a)array b)double linked list c)circular queue d)hash table Value-Labs 2
can anyone proide me reading material on please thanx in advance IBM 1
what is the output of below int n=10; (n++)++; printf("%d",n);   3
code for bubble sort?   1
int zap(int n) { if(n<=1)then zap=1; else zap=zap(n-3)+zap(n-1); } then the call zap(6) gives the values of zap [a] 8 [b] 9 [c] 6 [d] 12 [e] 15 Wipro 9
main() { int i; printf("%d",i^i); }   1
For more C Interview Questions Click Here 

Copyright Policy  |  Terms of Service  |  Articles  |  Site Map  |  RSS Site Map  |  Contact Us
Copyright © 2013  All Rights Reserved.   ::