C Program to convert decimal number to binary - c programs
//C Program to convert decimal number to binary
// Decimal number to binary conversion in c
// Decimal number to binary conversion using c language
#include <stdio.h>
void main()
{
int i=0,n,b[100];
printf("\n For Decimal to Binary converstion");
printf("\nEnter decimal number: ";
scanf("%d",&n);
while (n>0)
{
b[i]=n%2;
n=n/2;
i++;
}
printf("\nBinary is: ");
while(i>0)
{
printf(b[i]);
i--;
}
}
output:
For Decimal to Binary converstion
Enter decimal number:2
Binary is: 10
// Decimal number to binary conversion in c
// Decimal number to binary conversion using c language
#include <stdio.h>
void main()
{
int i=0,n,b[100];
printf("\n For Decimal to Binary converstion");
printf("\nEnter decimal number: ";
scanf("%d",&n);
while (n>0)
{
b[i]=n%2;
n=n/2;
i++;
}
printf("\nBinary is: ");
while(i>0)
{
printf(b[i]);
i--;
}
}
output:
For Decimal to Binary converstion
Enter decimal number:2
Binary is: 10
No comments:
Post a Comment