how to convert binary to decimal and decimal to binary in C
lanaguage
Answer Posted / sheela
#include<stdio.h>
#include<conio.h>
#include<math.h>
int main()
{
int n,r,s=0,i=0;
printf("\nEnter the binary number ");
scanf("%d",&n);
while(n>0)
{
r=n%10;
n=n/10;
s=s+r*pow(2,i++);
}
printf("\nThe binary equivalent is ");
printf("%d",s);
getch();
}
| Is This Answer Correct ? | 10 Yes | 2 No |
Post New Answer View All Answers
What are the 4 types of programming language?
What is the general form of #line preprocessor?
What are the different file extensions involved when programming in C?
What does 3 periods mean in texting?
Explain how does flowchart help in writing a program?
When a c file is executed there are many files that are automatically opened what are they files?
Explain what is meant by high-order and low-order bytes?
i have to apply for rbi before that i need to know the the syllabus for the entrance questions. whethet it may be aps or techinical
What are predefined functions in c?
Explain what is the difference between the expression '++a' and 'a++'?
in any language the sound structure of that language depends on its a) character set, input/output function, its control structures b) character set, library functions, input/output functions its control structures c) character set, library functions, control sturctures d) character set, operators, its control structures
What are the main characteristics of c language describe the structure of ac program?
What are bitwise shift operators in c programming?
What is the purpose of type declarations?
Create a structure to specify data on students as given below: Roll number, Name, Department, Course, and Year of joining. Assume that there are not more than 450 students in the collage. (a) Write a function to print the names of all students who joined in the last 3 years. (b) Write a function to print the data of a student whose roll numbers are divisible by 4.