how to find the binary of a number?

Answers were Sorted based on User's Feedback



how to find the binary of a number?..

Answer / ashu

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 ?    11 Yes 4 No

how to find the binary of a number?..

Answer / siddiqui mohd. faisal

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 ?    10 Yes 3 No

how to find the binary of a number?..

Answer / vaibhav

divide no. by 2 till 1 is not coming in quotient, then it
write from bottom to top

Is This Answer Correct ?    7 Yes 2 No

how to find the binary of a number?..

Answer / santhi perumal

#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 ?    9 Yes 6 No

how to find the binary of a number?..

Answer / alle balraj

void main()
{
int i,n,p=0,j;
int a[10];
clrscr();
printf("Enter the value of n:\n");
scanf("%d",&n);
i=n;
while(i!=1)
{
if(n==1)
{
a[p]=1;
break;
}
if(n%2==0)
{
a[p]=n%2;
}
else
{
a[p]=n%2;
}
n=n/2;
i=n+2;
i--;
p++;
}
for(j=p;j>=0;j--)
{
printf("%d",a[j]);
}

getch();
}

Is This Answer Correct ?    5 Yes 2 No

how to find the binary of a number?..

Answer / bertilla

#include<conio.h>
#include<stdio.h>
void main()
{
int i,n,arr[15];
for(i=0;i<=14;i++){arr[i]=0;}
do
{
arr[i]=n%2;
n=n/2;
i--;
if(n==1){arr[i]=1;}
}while(n>1);
for(i=0;i<=15;i++)
{
printf("%d",arr[i]);
}
getch();
}

Is This Answer Correct ?    2 Yes 1 No

how to find the binary of a number?..

Answer / naresh m

main()
{
int a[12],n,m,i=0;
printf("enter the no to find binary no's");
scanf("%d",&n);
while(n!=0)
{
m=i++;
a[i]=n%2;
n=n/2;
}
printf("binary value is");
for(i=m;i>=0;i--)
{
printf("%d",a[i]);
}

Is This Answer Correct ?    2 Yes 1 No

how to find the binary of a number?..

Answer / kk

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 ?    7 Yes 8 No

how to find the binary of a number?..

Answer / a.balraj

void main()
{
int i,n,p=0,temp,z;
int a[3];
clrscr();
printf("Enter the value of n:\n");
scanf("%d",&n);
i=n;
while(i!=1)
{
if(n%2==0)
{
temp=n%2;
}
else
{
temp=n%2;
}
a[p]=temp;
n=n/2;
i=n+2;
i--;
p++;
}
for(z=sizeof(a)/sizeof(int);z>=0;z--)
{
printf("%d",a[z]);
}
getch();
}

Is This Answer Correct ?    2 Yes 4 No

how to find the binary of a number?..

Answer / subhashini

#include<stdio.h>
#include<conio.h>
{
clrscr();
int i,sum,n;
printf("enter the number");
scanf("%d",&n);
while(n>=1)
{
i=n%2;
sum=sum*10+i;
n=n/2;
getch();
}
printf("the binary number is: %d",i)

Is This Answer Correct ?    0 Yes 4 No

Post New Answer

More C Interview Questions

Result of the following program is main() { int i=0; for(i=0;i<20;i++) { switch(i) case 0:i+=5; case 1:i+=2; case 5:i+=5; default i+=4; break;} printf("%d,",i); } } a)0,5,9,13,17 b)5,9,13,17 c)12,17,22 d)16,21 e)syntax error

8 Answers   IBM,


can any one provide me the notes of data structure for ignou cs-62 paper

0 Answers   Ignou,


WAP that prints the number from 1 to 100. but for multiplies of three print "XXX" instead of the number and for the multiplies of five print "YYY" . for number which are multiplies of both three and five print "ZZZ"

3 Answers  


Are enumerations really portable?

0 Answers  


There are N egg baskets and the number of eggs in each basket is a known quantity. Two players take turns to remove these eggs from the baskets. On each turn, a player must remove at least one egg, and may remove any number of eggs provided they all belong to the same basket. The player picking the last egg(s) wins the game. If you are allowed to decide who is going to start first, what mathematical function would you use to decide so that you end up on the winning side?

1 Answers   Hathway,






what is ANSI and ISO

7 Answers   HCL,


main() { int i=0; while(+(+i--)!=0) i-=i++; printf("%d",i); }

4 Answers  


How are pointers declared in c?

0 Answers  


wat is the output #define VOLEDEMORT _who_must_not_be_named int main() { printf("VOLEDEMORT"); }

2 Answers  


what is c++ programming?

3 Answers   TCS,


what is difference between strcmp & palindrome?

3 Answers  


Given only putchar (no sprintf, itoa, etc.) write a routine putlong that prints out an unsigned long in decimal. [ I gave the obvious solution of taking % 10 and / 10, which gives us the decimal value in reverse order. This requires an array since we need to print it out in the correct order. The interviewer wasn't too pleased and asked me to give a solution which didn't need the array ].

0 Answers  


Categories