The document provides 17 bitwise operator programming problems including setting, clearing, and toggling bits, determining if a number is even, positive or negative, swapping numbers, checking if a number is a power of 2, rotating bits, converting case of characters, reversing bits, comparing numbers, printing binary representations, swapping bytes of a hexadecimal number, deleting bits from a position, swapping nibbles, extracting bits, clearing a bit, and storing bits from a character buffer into integers. Students are asked to write programs to solve each problem using bitwise operators and the document provides examples for some problems.
The document provides 17 bitwise operator programming problems including setting, clearing, and toggling bits, determining if a number is even, positive or negative, swapping numbers, checking if a number is a power of 2, rotating bits, converting case of characters, reversing bits, comparing numbers, printing binary representations, swapping bytes of a hexadecimal number, deleting bits from a position, swapping nibbles, extracting bits, clearing a bit, and storing bits from a character buffer into integers. Students are asked to write programs to solve each problem using bitwise operators and the document provides examples for some problems.
--------------------------------------------------------------------------------------------------------------1. Write a prorgram for the following one.
a) Set a bit b) Clear a bit c) Toggle a bit 2. WAP to find the given number is even or odd using bitwise operators. 3. WAP to find the given number is +ve or -ve using bitwise operators. 4. WAP to swap two numbers using bitwise operators. 5. WAP to find the given number is power of 2 or not. 6. WAP to find the given number is divisble by 8 or not using bitwise operators. 7. Write a program to rotate the bits. Input the no.of rotations, at runtime. Ex : binary : 10000000000000000000000000001011 rotations : suppose 3 times right, then result : 01110000000000000000000000000001 binary : 10000000000000000000000000001011 rotations : suppose 4 times left, then result : 00000000000000000000000010111000 8. Convert the characters Upper to Lower and Lower to Upper using bitwise operators. 9. Write a program to reverse the bits of a given number. Note : not just reverse printing. 10. Write a one line code to compare two numbers equal or not using bitwise operators. 11. Write a program to print float binay formation using char *ptr. 12. Write a program to swap the adjucent bytes of a given 4-digit hexadecimal number. Ex : given number = 0x1234; after swap : 0x3412; 13. Write a program to delete no.of bits from particular position in a given number. Input the no.of bits, at runtime. Ex: Suppose num = 100; It's Binaray is 00000000000000000000000001100100 delete 2 bits from 4th position then result is 00000000000000000000000000011100 14. Write a programme for swapping first and last nibbles in a given integer. Ex: Suppose num = 10
15. Write a logic to extract P bits from Posion N in an integer M
16. Write a macro to clear a bit at the position N in an integer M. 17. There are 48 bits are stored in an array of character buffer and store them into 2 integer variables. -------------------------------------------------------- END -------------------------------------------------------Dear Students, if any mistakes found, Kindly inform to me. A.Tandava Ramakrishna