/*Convert Decimal to Binary*/
#include<stdio.h> #include<conio.h> void main() { clrscr(); int a,b,x,y,i[5],j,r; printf("Enter no."); scanf("%d",&a); x=a%2; y=a/2; b=(y*2)+(x); for(j=0;b!=0;b/=2) { i[j]=b%2; j++; } for(r=j-1;r>=0;r--) { printf("%d",i[r]); } getch(); }
No comments:
Post a Comment