how to convert binary to decimal and decimal to binary in C
lanaguage

Answer Posted / ruchi

#include<stdio.h>
#include<conio.h>
#include<math.h>
int main()
{
int n,r,s=0,i=0;
printf("\nEnter the decimal number ");
scanf("%d",&n);
while(n>0)
{
r=n%2;
n=n/2;
s=s+r*pow(10,i++);
}
printf("\nThe binary equivalent is ");
printf("%d",s);
getch();
}

Is This Answer Correct ?    27 Yes 17 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What should malloc(0) do? Return a null pointer or a pointer to 0 bytes?

583


What is the difference between printf and scanf )?

585


What are the types of i/o functions?

675


What is a program?

655


the process of defining something in terms of itself is called (or) in C it is possible for the functions to call themselves. A function called a) nested function b) void function c) recursive function d) indifinite function

754






Is c pass by value or reference?

593


How can I remove the leading spaces from a string?

626


What is a struct c#?

599


What are header files why are they important?

574


Which is the best website to learn c programming?

576


What is a stream water?

650


What is difference between structure and union?

593


1) There is a singing competition for children going to be conducted at a local club. Parents have been asked to arrive at least an hour before and register their children’s names with the Program Manager. Whenever a participant registers, the Program Manager has to position the name of the person in a list in alphabet order. Write a program to help the Program Manager do this by placing the name in the right place each time the Program Manger enters a name. 2) the Event Manager has to send participants to the stage to perform in the order in which they registered. Write a program that will help the Event Manager know who to call to the stage to perform. The Logic should be in Data Structures

2736


Explain the advantages of using macro in c language?

572


What is #include cctype?

574