how to find binary of number?
Answers were Sorted based on User's Feedback
Answer / abhishek karnani
Here is a prgm to convert a decimal number to any base just
replace 2 by the base number of the desired number
#include<stdio.h>
#include<conio.h>
void main()
{
int d;
int i=0,n,j,b[100];
clrscr();
printf("\nEnter decimal number: ");
scanf("%d",&n);
while (n>0)
{
b[i]=n%2;
n=n/2;
i++;
}
printf("\nBinary is: ");
for (j=i-1;j>=0;j--)
{
printf("%d",b[j]);
}
getch();
}
Is This Answer Correct ? | 4 Yes | 0 No |
Answer / kamalb008
#include<stdio.h>
main()
{
int a,i,b,n;/*i have taken arbitary base u can enter the
base what ever u need*/
printf("enter the number and the base u want to conv resp");
scanf("%d%d",&a,&n);
i=1;
while(i<=20)
{
if(a<n)
break;
b=a%n;
a=a/n;
printf("\nLSB%d of the converted number is %d",i,b);
i++;
}
printf("\nMSB of the conv is %d",a);
}
Is This Answer Correct ? | 1 Yes | 1 No |
Explain what math functions are available for integers? For floating point?
Explain what is wrong with this program statement? Void = 10;
In c programming language, how many parameters can be passed to a function ?
print ur name without using any semicolon in c/c++....
21 Answers Bosch, TCS, Wipro,
char S; char S[6]= " HELLO"; printf("%s ",S[6]); output of the above program ? (0, ASCII 0, I,unpredictable)
How a string is stored in c?
Why isn't any of this standardized in c? Any real program has to do some of these things.
how does the for loop work actually..suppose for the following program how it ll work plz explain to me for(i=5;i>=0;i--) prinf(i--);
how to generate sparse matrix in c
What does the error message "DGROUP exceeds 64K" mean?
What is the purpose of sprintf?
write a c program to find the sum of five entered numbers using an array named number