#include #include void main(void) { unsigned int a, b, mask=1; int n; char lr; do { clrscr(); //do-while printf("Enter the SIDE from which to start " "(L: Left, R:Right)... "); lr=getch(); } while(lr!='l' && lr!='L' && lr!='r' && lr!='R'); if(lr=='L') lr='l'; if(lr=='R') lr='r'; while(1) { if(lr=='r') printf("\nEnter the no. to be ***" " (greater than 511): "); if(lr=='l') printf("\nEnter the no. to be *** " "(less than 128): "); scanf("%d",&a); if(lr=='r' && a>511) break; else if(lr=='l' && a<128) break; else continue; } do { printf("Enter the no. bits (1 to 16) "); scanf("%d",&n); } while(n<0 || n>16); mask<<=n; mask-=1; b = a & mask; printf("%u\n",b); puts("O/P is:"); int i=0; a=wherey(); while(b!=0) { gotoxy(n-i , a); printf("%d",b%2); b/=2; i++; } while((n-i)!=0) { gotoxy(n-i , a); printf("0"); i++; } printf("\n"); while(!kbhit()) ; //getch(); }