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
difference between native and cross compilers
What are multidimensional arrays?
Write the Program to reverse a string using pointers.
What is FIFO?
Write a C++ program to generate 10 integer numbers between - 1000 and 1000, then store the summation of the odd positive numbers in variable call it sum_pos, then find the maximum digit in this variable regardless of its digits length.
What is the use of void pointer and null pointer in c language?
Is it better to bitshift a value than to multiply by 2?
What does void main () mean?
What is && in c programming?
How can I implement sets or arrays of bits?
What are structural members?
What are examples of structures?
What are lookup tables in c?
Explain what is wrong with this program statement? Void = 10;
What are the types of variables in c?