Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- Program implementat de Nan Mihai
- Pregatire examen restanta PC - 2014
- */
- /*
- Enunt: Afisarea unui numar intreg fara semn in binar folosind extragerea
- selectiva de biti cu o masca ce contine un singur bit 1
- */
- #include <stdlib.h>
- #include <stdio.h>
- int main ()
- {
- int n;
- scanf("%d",&n);
- unsigned int mask = 1<<15; //bitul 15 =1 si restul zero(128)
- while (mask)
- {
- printf ("%d", (mask & d) ? 1: 0);
- //Deplasare masca la dreapta cu un bit
- mask >>= 1;
- }
- printf("\n");
- }
Advertisement
Add Comment
Please, Sign In to add comment