C Program which convert decimal number to binary numbers:
#include <stdio.h>
main()
{
int n, c, k;
printf("Enter an integer in decimal number system: ");
scanf("%d",&n);
printf("%d in binary number system is: ",n);
for (c = 31; c >= 0; c--)
{
k = n >> c;
if (k & 1)
printf("1");
else
printf("0");
}
}
Also by Making Function of it:
#include <stdio.h>
void dectobin(int);
main()
{
int n;
printf("Enter an integer in decimal number system: ");
scanf("%d",&n);
dectobin(n);
}
void dectobin(int n)
{
int c,k;
printf("%d in binary number system is: ",n);
for (c = 31; c >= 0; c--)
{
k = n >> c;
if (k & 1)
printf("1");
else
printf("0");
}
}
{[['
']]}

0 comments:
Post a Comment
Click to see the code!
To insert emoticon you must added at least one space before the code.