how to convert binary to decimal and decimal to binary in C
lanaguage
Answer Posted / rahul
[decimal to binary]
#include<stdio.h>
#include<conio.h>
void main()
{
int dec,bin,a[100],i=0,r,j;
printf("enter the decimal number: ");
scanf("%d",&dec);
while(dec>0)
{
r=dec%2;
dec=dec/2;
a[i]=r;
i++;
}
printf("the equivalant binary numberis: ");
for(j=i-1;j>=0;j--)
printf("%d",a[j]);
getch()
}
Is This Answer Correct ? | 72 Yes | 32 No |
Post New Answer View All Answers
How will you write a code for accessing the length of an array without assigning it to another variable?
How can you tell whether two strings are the same?
can any one tel me wt is the question pattern for NIC exam
write a program to convert a expression in polish notation(postfix) to inline(normal) something like make 723+* (2+3) x 7 (not sure) just check out its mainly printing expression in postfix form to infix.
Find MAXIMUM of three distinct integers using a single C statement
What is the use of function in c?
What are enumerated types?
given post order,in order construct the corresponding binary tree
What is c language & why it is used?
Why is c called c not d or e?
Write the test cases for checking a variable having value in range -10.0 to +10.0?
write a C program: To search a file any word which starts with ?a?. If the word following this ?a? starts with a vowel.Then replace this ?a? with ?a? with ?an?. redirect with the output onto an output file.The source file and destination file are specified by the user int the command line.
Why do we need volatile in c?
using only #include
What does 4d mean in c?