Write a program that will compute the binary equivalent number of a decimal number and print it as output.
C Programming Language Loop control in C Language (Article) Loop control in C Language (Program)
785Program:
#include int main() { int a[20],i,m,n,r; printf("\n Enter the decimal Integer "); scanf("%d",&n); m=n; for(i=0;n>0;i++) { r=n%2; a[i]=r; n=n/2; } printf("\n Binary equivalent of %d is \t",m); for(i--;i>=0;i--) printf("%d",a[i]); return 0; }
Output:
Enter the decimal Integer 10 Binary equivalent of 10 is 1010 -------------------------------- Process exited after 3.289 seconds with return value 0 Press any key to continue . . .
Explanation:
None
This Particular section is dedicated to Programs only. If you want learn more about C Programming Language. Then you can visit below links to get more depth on this subject.