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


Please Help Members By Posting Answers For Below Questions

When should volatile modifier be used?

548


What do you know about the use of bit field?

606


What are data types in c language?

578


What is data structure in c programming?

567


What is the size of array float a(10)?

651






What is the use of a semicolon (;) at the end of every program statement?

764


In a header file whether functions are declared or defined?

627


What is difference between arrays and pointers?

575


what are non standard function in c

1429


What is the best way to store flag values in a program?

576


Can you assign a different address to an array tag?

694


Differentiate between calloc and malloc.

751


What is structure and union in c?

594


Write a Program to find whether the given number or string is palindrome.

607


Explain how do you declare an array that will hold more than 64kb of data?

895