bsc

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

luc111.c (969B)


      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. Check if 3rd and 5th bits are OFF. If yes, put them ON.
      9 */
     10 /* Let Us C, Chap- 21 (Operations on Bits), Qn No.: B(i) */
     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;
     22     unsigned char mask = (1 << 3) | (1 << 5);
     23 
     24     printf("Enter an 8-bit number: ");
     25     scanf("%hhu", &num);
     26 
     27     // Check if bits are OFF. (num & mask) should be 0.
     28     if ((num & mask) == 0)
     29     {
     30         printf("Bits 3 and 5 are OFF. Turning them ON...\n");
     31         num = num | mask;
     32     }
     33     else
     34     {
     35         printf("Bits 3 and 5 are NOT both OFF. No change.\n");
     36     }
     37 
     38     printf("Final Value: %d (0x%02X)\n", num, num);
     39 
     40     return 0;
     41 }
© notamitgamer • Site Built: 2026-07-21 13:58:23 UTC • git-mirror commit: 1037f62 [view raw info]
Originally created with stagit • modified by notamitgamer
Forked from github.com/notamitgamer/git-mirror