geeksforgeeks
search icon
  • Courses
    Sale
  • Tutorials
  • Interview Prep
    Videos
    August 13, 2024 |20.4K Views

    Check whether K-th bit is set or not

    Strings, String, bit-magic
     Save  Share   Like
    Description
    Discussion

    Given a number n, check if the Kth bit of n is set or not.
     

    Examples:

    Input : n = 5, k = 1
    Output : SET
    5 is represented as 101 in binary and has its first bit set.

    Input : n = 2, k = 3
    Output : NOT SET
    2 is represented as 10 in binary, all higher i.e. beyond MSB, bits are NOT SET.


    Check whether K-th bit is set or not  : https://www.geeksforgeeks.org/check-whether-k-th-bit-set-not/

    Recommendations
    Video Thumbnail
    14:00
    Video Thumbnail
    5.1K Views | 16/01/2025...
    Print Concatenation of Zig-Zag String in ‘n’ Rows
    Video Thumbnail
    06:10
    Video Thumbnail
    201.0K Views | 11/01/2025...
    Return maximum occurring character in an input string
    Video Thumbnail
    17:16
    Video Thumbnail
    216.5K Views | 10/01/2025...
    Write a program to print all permutations of a given string
    Video Thumbnail
    09:32
    Video Thumbnail
    57.5K Views | 10/01/2025...
    Naive Algorithm for Pattern Searching
    Video Thumbnail
    15:26
    Video Thumbnail
    13.1K Views | 09/01/2025...
    String matching where one string contains wildcard characters
    Video Thumbnail
    09:44
    Video Thumbnail
    13.7K Views | 09/01/2025...
    Check whether a given string is an interleaving of two other given strings
    Video Thumbnail
    03:00
    Video Thumbnail
    9.4K Views | 07/01/2025...
    Remove minimum number of characters so that two strings become anagram
    Video Thumbnail
    03:43
    Video Thumbnail
    6.3K Views | 06/01/2025...
    Reverse string without using any temporary variable
    Video Thumbnail
    07:09
    Video Thumbnail
    39.0K Views | 23/08/2024...
    A Program to check if strings are rotations of each other or not
    Video Thumbnail
    14:42
    Video Thumbnail
    19.3K Views | 13/08/2024...
    Camel case of a given sentence
    GeeksforGeeks
    location
    Corporate & Communications Address:
    A-143, 6th Floor, Sovereign Corporate Tower, Sector- 136, Noida, Uttar Pradesh (201305)
    location
    Registered Address:
    K 061, Tower K, Gulshan Vivante Apartment, Sector 137, Noida, Gautam Buddh Nagar, Uttar Pradesh, 201305
    GFG App on Play StoreGFG App on App Store
    • Company
    • About Us
    • Legal
    • Privacy Policy
    • Contact Us
    • Advertise with us
    • GFG Corporate Solution
    • Campus Training Program
    • Explore
    • POTD
    • Job-A-Thon
    • Blogs
    • Nation Skill Up
    • Tutorials
    • Programming Languages
    • DSA
    • Web Technology
    • AI, ML & Data Science
    • DevOps
    • CS Core Subjects
    • Interview Preparation
    • Software and Tools
    • Courses
    • ML and Data Science
    • DSA and Placements
    • Web Development
    • Programming Languages
    • DevOps & Cloud
    • GATE
    • Trending Technologies
    • Videos
    • DSA
    • Python
    • Java
    • C++
    • Web Development
    • Data Science
    • CS Subjects
    • Preparation Corner
    • Interview Corner
    • Aptitude
    • Puzzles
    • GfG 160
    • System Design
    @GeeksforGeeks, Sanchhaya Education Private Limited, All rights reserved