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

Compare array data type to pointer data type

596


What is preprocessor with example?

578


Is that possible to store 32768 in an int data type variable?

687


Can you tell me how to check whether a linked list is circular?

764


WRITE A CODE IN C TO SEARCH A FILE FROM NOTEPAD FILE.

2023






Explain why C language is procedural?

766


what are bit fields? What is the use of bit fields in a structure declaration?

1497


Difference between constant pointer and pointer to a constant.

607


How can you tell whether two strings are the same?

826


What is hungarian notation? Is it worthwhile?

693


What is the difference between malloc calloc and realloc in c?

643


Does c have enums?

598


write a C program: To recognize date of any format even formats like "feb-02-2003","02-february-2003",mm/dd/yy, dd/mm/yy and display it as mm/dd/yy.

3332


What does node * mean?

705


What is the meaning of typedef struct in c?

591