Answer Posted / abhishek karnani
Here is a prgm to convert a decimal number to any base just
replace 2 by the base number of the desired number
#include<stdio.h>
#include<conio.h>
void main()
{
int d;
int i=0,n,j,b[100];
clrscr();
printf("\nEnter decimal number: ");
scanf("%d",&n);
while (n>0)
{
b[i]=n%2;
n=n/2;
i++;
}
printf("\nBinary is: ");
for (j=i-1;j>=0;j--)
{
printf("%d",b[j]);
}
getch();
}
Is This Answer Correct ? | 4 Yes | 0 No |
Post New Answer View All Answers
Explain how can I convert a string to a number?
Differentiate between a for loop and a while loop? What are it uses?
Why main is not a keyword in c?
What's the best way of making my program efficient?
What is the scope of static variable in c?
What is a function simple definition?
What does emoji p mean?
how logic is used
What is c programing language?
What is a function in c?
What is the difference between the expression “++a” and “a++”?
What is getch c?
What is the right type to use for boolean values in c? Is there a standard type?
What is the usage of the pointer in c?
What is header file in c?