luc109.c (814B)
1 /* 2 * Author : Amit Dutta <amitdutta4255@gmail.com> 3 * Date : 08 Feb 2026 4 * Repo : https://github.com/notamitgamer/bsc 5 * License : MIT License (See the LICENSE file for details) 6 */ 7 8 /* Receive an 8-bit number and set its odd bits to 1. 9 */ 10 /* Let Us C, Chap- 21 (Operations on Bits), Qn No.: B(g) */ 11 12 /* This file is auto-generated by a bot. */ 13 /* This code is not compiled; it is for reference only. */ 14 15 16 #include <stdio.h> 17 #include <stdlib.h> 18 19 int main() 20 { 21 unsigned char num, res; 22 23 printf("Enter an 8-bit number: "); 24 scanf("%hhu", &num); 25 26 // Odd bits usually refer to positions 1, 3, 5, 7. 27 // Mask: 1010 1010 (binary) = 0xAA 28 // OR operation sets bits to 1. 29 30 res = num | 0xAA; 31 32 printf("Original: 0x%02X\n", num); 33 printf("Result: 0x%02X\n", res); 34 35 return 0; 36 }