how to convert binary to decimal and decimal to binary in C
lanaguage
Answer Posted / rahul
[decimal to binary]
#include<stdio.h>
#include<conio.h>
void main()
{
int dec,bin,a[100],i=0,r,j;
printf("enter the decimal number: ");
scanf("%d",&dec);
while(dec>0)
{
r=dec%2;
dec=dec/2;
a[i]=r;
i++;
}
printf("the equivalant binary numberis: ");
for(j=i-1;j>=0;j--)
printf("%d",a[j]);
getch()
}
| Is This Answer Correct ? | 72 Yes | 32 No |
Post New Answer View All Answers
Explain what is operator promotion?
What are file streams?
Explain heap and queue.
What is a function in c?
What is a pragma?
How to write a multi-statement macro?
What are the loops in c?
How do you print only part of a string?
1.int a=10; 2.int b=20; 3. //write here 4.b=30; Write code at line 3 so that when the value of b is changed variable a should automatically change with same value as b. 5.
Explain is it better to bitshift a value than to multiply by 2?
What are the Advantages of using macro
How can you determine the maximum value that a numeric variable can hold?
why use "return" statement a) on executing the return statement it immediately transfers the control back to the calling program b) it returns the value present in the parentheses return, to the calling program c) a & b d) none of the above
What are the different types of data structures in c?
Write a program to produce the following output: 1 2 3 4 5 6 7 8 9 10