ALLInterview.com :: Home Page KalAajKal.com
 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                      
tip   SiteMap shows list of All Categories in this site.
Google
 
Categories  >>  Software  >>  Programming Languages  >>  C
 
 


 

 
 C interview questions  C Interview Questions
 C++ interview questions  C++ Interview Questions
 VC++ interview questions  VC++ Interview Questions
 Delphi interview questions  Delphi Interview Questions
 Programming Languages AllOther interview questions  Programming Languages AllOther Interview Questions
Question
how to find the binary of a number?
 Question Submitted By :: Kk
I also faced this Question!!     Rank Answer Posted By  
 
  Re: how to find the binary of a number?
Answer
# 1
divide the given no by two n store the remainder in stack 
and divide again by 2 to quotent the process gong on....
n store all the remainder in the same stack....
n in last pop all the element from stack n print it.
 
Is This Answer Correct ?    5 Yes 2 No
Ashu
 
  Re: how to find the binary of a number?
Answer
# 2
let the number be n
int bin(int n)
{
static int sum=0;

if(n>1)
{
rem=n%2;
sum = sum *10 +rem;
n=n/2;
bin(n);
}
else
{
sum=sum*10+1;
}
return sum;
}
 
Is This Answer Correct ?    5 Yes 2 No
Kk
 
 
 
  Re: how to find the binary of a number?
Answer
# 3
It's very simple.
Firstly, the binary no. of 0 is 0000.
After that if you want to know the binary no. of 1 then 
jaust add 1 to binary no. of 0 i.e. 0000.So, now the ans 
will be 0001.But,remember here 1+1=10.So, now if you want 
binary no. of 2 then add 1 to binary no. of 1 i.e. 0001.So, 
the binary no. of 2 will be 0010.
I hope you got your question answer.
 
Is This Answer Correct ?    3 Yes 1 No
Siddiqui Mohd. Faisal
 
  Re: how to find the binary of a number?
Answer
# 4
#include<stdio.h>
#include<conio.h>

int main()
{
	int i,number;
	printf("Enter the Number\n");
	scanf("%d",&number);

	for(i=7;i>=0;i--)
	{
		if((1<<i) & number)
			 printf("1");
		else
			 printf("0");
	}
}
 
Is This Answer Correct ?    3 Yes 1 No
Santhi Perumal
 
  Re: how to find the binary of a number?
Answer
# 5
divide no. by 2 till 1 is not coming in quotient, then it 
write from bottom to top
 
Is This Answer Correct ?    4 Yes 0 No
Vaibhav
 

 
 
 
Other C Interview Questions
 
  Question Asked @ Answers
 
Every time i run a c-code in editor, getting some runtime error and editor is disposing, even after reinstalling the software what may be the problem?  2
Give a fast way to multiply a number by 7 Microsoft8
15.what is the disadvantage of using macros? 16.what is the self-referential structure? 17.can a union be self-referenced? 18.What is a pointer? 19.What is the Lvalue and Rvalue? 20.what is the difference between these initializations? 21.Char a[]=”string”; 22.Char *p=”literal”; 23.Does *p++ increment p, or what it points to? CTS2
True or false: If you continuously increment a variable, it will become negative? 1) True 2) False 3) It depends on the variable type  5
what is the difference between declaration ,defenetion and initialization of a variable? LG-Soft5
WAP to accept first name,middle name & last name of a student display its initials? NIIT2
What is structure packing ? HP1
how to add numbers without using arithmetic operators. TCS10
Print the foll in C...eg when n=5 the o/p must b + + + + + + + + + + + + + + + + +  1
wt is d full form of c Wipro1
can i know the source code for reversing a linked list with out using a temporary variable? Honeywell6
sqrt(x+sqrt(x+sqrt(x+sqrt(x))))=2; Find the value of x? Subex2
how memory store byte Huawei3
what does exit() do? Cadence3
Write a Program to print this triangle: * ** * **** * ****** * ******** * ********** use two nested loops. TCS5
what is the hexidecimal number of 4100? Google14
Write a program to write a given string in maximum possibilities? i.e str[5]="reddy"; i.e we can write this string in 120 ways for that write a program Subex3
enum day = { jan = 1 ,feb=4, april, may} what is the value of may? a)4 b)5 c)6 d)11 e)none of the above HCL2
int *p=20; if u print like dis printf("%d",p); o\p:- 20; how is it possible? plz give me the explanation. Global-Edge11
print the following using nested for loop. 5 4 3 2 1 1 2 3 4 3 2 1 1 2 1 2 1 1 2 3 4 3 2 1 1 2 3 4 5  5
 
For more C Interview Questions Click Here 
 
 
 
 
 
   
Copyright Policy  |  Terms of Service  |  Help  |  Site Map 1  |  Articles  |  Site Map  |   Site Map  |  Contact Us interview questions urls   External Links 
   
Copyright © 2007  ALLInterview.com.  All Rights Reserved.

ALLInterview.com   ::  Forum9.com   ::  KalAajKal.com