how to convert binary to decimal and decimal to binary in C
lanaguage
Answer Posted / saravana priya
#include <stdio.h>
void main()
{
int num, bnum, dec = 0, base = 1, rem ;
printf(“Enter a binary number(1s and 0s)\n”);
scanf(“%d”, &num); /*maximum five digits */
bnum = num;
while( num > 0)
{
rem = num % 10;
dec = dec + rem * base;
num = num / 10 ;
base = base * 2;
}
printf(“The Binary number is = %d\n”, bnum);
printf(“Its decimal equivalent is =%d\n”, dec);
} /* End of main() */
Is This Answer Correct ? | 25 Yes | 9 No |
Post New Answer View All Answers
How would you obtain the current time and difference between two times?
Explain pointers in c programming?
what is the difference between class and unio?
How does selection sort work in c?
What is string function c?
how can i access hard disk address(physical address)? are we access hard disk by using far,near or huge pointer? if yes then please explain.....
How can I make it pause before closing the program output window?
Write programs for String Reversal & Palindrome check
What is typedef example?
What is time null in c?
What are static variables in c?
What is double pointer in c?
How does #define work?
Why is C language being considered a middle level language?
A text file that contains declarations used by a group of functions,programs,or users a) executable file b) header file c) obj file d) .cfile