Write a C program to check Least Significant Bit (LSB) of number is set or not.


#include 

int main()
{
    int num;

    /* Input number from user */
    printf("Enter any number: ");
    scanf("%d", &num);

    /* If (num & 1) evaluates to 1 */
    if(num & 1)
        printf("LSB of %d is set (1).", num);
    else
        printf("LSB of %d is unset (0).", num);

    return 0;
}
Write a C program to check Least Significant Bit (LSB) of number is set or not. Write a C program to check Least Significant Bit (LSB) of number is set or not. Reviewed by on August 30, 2019 Rating: 5
Powered by Blogger.