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 is indirection in c?

835


How pointer is different from array?

861


What is static and volatile in c?

1011


What is a structure in c language. how to initialise a structure in c?

857


if a is an integer variable, a=5/2; will return a value a) 2.5 b) 3 c) 2 d) 0

1731


Create a registration form application by taking the details like username, address, phone number, email with password and confirm password (should be same as password).Ensure that the password is of 8 characters with only numbers and alphabets. Take such details for 3 users and display the details. While taking input password must appear as “****”.

2960


Why main is not a keyword in c?

936


Is null equal to 0 in sql?

896


What are the uses of null pointers?

809


What does calloc stand for?

873


Can you define which header file to include at compile time?

826


How do you use a 'Local Block'?

958


Why c is called procedure oriented language?

825


is it possible to create your own header files?

866


Write a C Program That Will Count The Number Of Even And Odd Integers In A Set using while loop

1951