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
When should volatile modifier be used?
What do you know about the use of bit field?
What are data types in c language?
What is data structure in c programming?
What is the size of array float a(10)?
What is the use of a semicolon (;) at the end of every program statement?
In a header file whether functions are declared or defined?
What is difference between arrays and pointers?
what are non standard function in c
What is the best way to store flag values in a program?
Can you assign a different address to an array tag?
Differentiate between calloc and malloc.
What is structure and union in c?
Write a Program to find whether the given number or string is palindrome.
Explain how do you declare an array that will hold more than 64kb of data?