write a c program to check weather a particluar bit is set
or not?

Answer Posted / abdur rab

#include <stdio.h>

int main ()
{
int variable = 6;
int position = 3;
char array [2][10] = {"NOT SET", "SET"};

// check the wheather the second bit is set
printf ( "\n The bit is %s",
array [ ( variable & ( 1 << (
position - 1 ) ) ) / position ] );
return ( 0 );
}

Is This Answer Correct ?    2 Yes 3 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What does the function toupper() do?

881


What is infinite loop?

852


What is a sequential access file?

872


What functions are used for dynamic memory allocation in c language?

868


Tell us bitwise shift operators?

809


What is c method?

749


What is the difference between abs() and fabs() functions?

866


Explain what math functions are available for integers? For floating point?

855


How can you find the day of the week given the date?

852


Write program to remove duplicate in an array?

823


any C program contains only one function, it must be a) void () b) main () c) message () d) abc ()

924


What is const volatile variable in c?

790


Can we add pointers together?

824


What is hash table in c?

781


How would you rename a function in C?

813