bsc

Comprehensive codebase and cou...
Log | Files | Refs | Activity | README | LICENSE

root / semester_1 / letusc / luc109.c

luc109.c (623B)


      1 /* Receive an 8-bit number and set its odd bits to 1.
      2 */
      3 /* Let Us C, Chap- 21 (Operations on Bits), Qn No.: B(g) */
      4 
      5 /* This file is auto-generated by a bot. */
      6 /* This code is not compiled; it is for reference only. */
      7 
      8 
      9 #include <stdio.h>
     10 #include <stdlib.h>
     11 
     12 int main()
     13 {
     14     unsigned char num, res;
     15 
     16     printf("Enter an 8-bit number: ");
     17     scanf("%hhu", &num);
     18 
     19     // Odd bits usually refer to positions 1, 3, 5, 7.
     20     // Mask: 1010 1010 (binary) = 0xAA
     21     // OR operation sets bits to 1.
     22     
     23     res = num | 0xAA;
     24 
     25     printf("Original: 0x%02X\n", num);
     26     printf("Result:   0x%02X\n", res);
     27 
     28     return 0;
     29 }
© notamitgamer • Site Built: 2026-09-05 01:53:16 UTC • git-mirror commit: c170d72 [view raw info]
Originally created with stagit • modified by notamitgamer
Forked from github.com/notamitgamer/git-mirror