DECIMAL TO BINARY CONVERSION IN C
In this program , you will learn to write a program to convert Decimal numbers into Binary numbers.
Output:
Try this code by your own!
To understand this Decimal number to Binary number conversion program, you must have basic knowledge about Decimal and Binary numbers.
Some binary numbers for the decimal numbers:
Program to convert Decimal number into binary number:
//convert decimal number to binary number
#include<stdio.h>
int main( )
{
int a[i], num, i;
printf("Enter the number:");
scanf("%d",&num);
for(i=0; n>0;i++)
{
a[i]=num%2;
num=num/2;
}
printf("\nBinary number for given number:");
for(i=i-1;i>=0;i--)
{
printf("%d",a[i]):
}
return 0;
}
#include<stdio.h>
int main( )
{
int a[i], num, i;
printf("Enter the number:");
scanf("%d",&num);
for(i=0; n>0;i++)
{
a[i]=num%2;
num=num/2;
}
printf("\nBinary number for given number:");
for(i=i-1;i>=0;i--)
{
printf("%d",a[i]):
}
return 0;
}
Output:
Enter the number: 5
Binary number for given number : 0101
Binary number for given number : 0101
Try this code by your own!
If you have any doubts , then feel free to drop a comment. I'll be happy to answer questions in the comment section.
Keep coding.....
Comments
Post a Comment