ALLInterview.com :: 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                      
Google
   
 
Categories >> Software >> Programming Languages >> C
 
 


 

 
 C interview questions  C Interview Questions (2265)
 C++ interview questions  C++ Interview Questions (1119)
 VC++ interview questions  VC++ Interview Questions (342)
 Delphi interview questions  Delphi Interview Questions (510)
 Programming Languages AllOther interview questions  Programming Languages AllOther Interview Questions (648)
Question
Write a C program to convert an integer into a binary 
string?
 Question Submitted By :: C
I also faced this Question!!     Answer Posted By  
 
Answer
# 1
#include<stdio.h>
char *IntToBinString(int no);
main()
{
int no;
printf("ENTER THE NO: ");
scanf("%d",&no);
printf("\nBINARY O/P STRING:\n%s",IntToBinString(no));
getch();
}
char *IntToBinString(int no)
{
char *ptr;
int i, size;
size = sizeof(int)*8;
ptr = (char *)malloc(sizeof(int)*8);
for(i = size - 1; i >= 0; i--)
{
if(no >> i & 0x01)
{
*ptr++ = 49;
}
else
{
*ptr++ = 48;
}
}
*ptr = '\0';
return (ptr - size);
}
 
Is This Answer Correct ?    9 Yes 3 No
VadivelT
 

 
 
 
Other C Interview Questions
 
  Question Asked @ Answers
 
Tell us the difference between these two : #include"stdio.h" #include<stdio.h> define in detial.   5
Difference between null pointer and dangling pointer? Wipro 7
# define x=1+4; main() { int x; printf("%d%d",x/2,x/4); }   5
what are the advantages & disadvantages of unions?   2
Write a C program to multiply tho numbers without using arithmetic operator (+, -, *, /).   1
how to make c program without a libary? e.g.#include<stdio.h> libary is not in c progaram.   2
How can I find leaf node with smallest level in a binary tree?   1
what is the advantage of using SEMAPHORES to ORDINARY VARIABLES??? NSN 2
why in C,C++'s int size is 2 byte and .net(c#) int Size is 4 byte?   2
int n=1; while(1) { switch(n) { case 1:printf("a"); n++; continue; case 2:printf("b"); n++; continue; default : printf("c"); break; } break; }   1
I have a function which accepts a pointer to an int. How can I pass a constant like 5 to it?   3
write a program that will accept two integers and will implement division without using the division operator if the second value is an odd number and will implement multiplication without using multiplication operator if the second value is an even number.   1
 
For more C Interview Questions Click Here 
 
 
 
 
 


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

ALLInterview.com   ::  KalAajKal.com