/* * Author : Amit Dutta * Date : 08 Feb 2026 * Repo : https://github.com/notamitgamer/bsc * License : MIT License (See the LICENSE file for details) */ /* Receive an 8-bit number and exchange its higher 4 bits with lower 4 bits. */ /* Let Us C, Chap- 21 (Operations on Bits), Qn No.: B(f) */ /* This file is auto-generated by a bot. */ /* This code is not compiled; it is for reference only. */ #include #include int main() { unsigned char num, swapped; printf("Enter an 8-bit number (0-255): "); scanf("%hhu", &num); // Exchange nibbles // (num & 0xF0) >> 4 : High nibble to Low // (num & 0x0F) << 4 : Low nibble to High swapped = ((num & 0xF0) >> 4) | ((num & 0x0F) << 4); printf("Original: %d (Hex: 0x%02X)\n", num, num); printf("Swapped: %d (Hex: 0x%02X)\n", swapped, swapped); return 0; }