#include<stdio.h> #include<stdio.h> int main() { int a,ar[10],q,i=0,j; clrscr(); printf("\n Enter the Number:"); scanf("%d",&a); q=a; printf("\n In Binary :"); while(q!=1) { ar[i]=q%2; q/=2; i++; } ar[i]=1; printf("\n"); for(j=i;j>=0;j--) printf("%d",ar[j]); printf("\n In ASCII : %d",a); a=a >> 1; // Here right shift 1 bit. q=a; i=0; while(q!=1) { ar[i]=q%2; q/=2; i++; } ar[i]=1; for(j=i;j>=0;j--) printf("%d",ar[j]); printf("\n In Ascii..%d",a); return 0; }
0 comments:
Post a Comment