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
Badboy is defined who has ALL the following properties: Does not have a girlfriend and is not married. He is not more than 23 years old. The middle name should be "Singh" The last name should have more than 4 characters. The character 'a' should appear in the last name at least two times. The name of one of his brothers should be "Ram" Write a method: boolean isBadBoy(boolean hasGirlFriend , boolean isMarried, int age , String middleName , String lastName , String[] brotherName); isHaveGirlFriend is true if the person has a girlfriend isMarried is true if the person is married age is the age of the person middleName is the middle name of the person lastName is the last name of the person brotherName is the array of the names of his brothers
How can I write a function that takes a format string and a variable number of arguments?
What are the different types of data structures in c?
What standard functions are available to manipulate strings?
What is a function in c?
If errno contains a nonzero number, is there an error?
Can you please explain the difference between malloc() and calloc() function?
What is the use of linkage in c language?
How can I rethow can I return a sequence of random numbers which dont repeat at all?
What is meant by preprocessor in c?
What is an example of structure?
FILE *fp1,*fp2; fp1=fopen("one","w") fp2=fopen("one","w") fputc('A',fp1) fputc('B',fp2) fclose(fp1) fclose(fp2)} a.error b. c. d.
What is the difference between exit() and _exit() function?
How do you print only part of a string?
How do you declare a variable that will hold string values?