Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

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 the value of h?

1043


How can I delete a file?

1067


The % symbol has a special use in a printf statement. How would you place this character as part of the output on the screen?

1281


Given only putchar (no sprintf, itoa, etc.) write a routine putlong that prints out an unsigned long in decimal. [ I gave the obvious solution of taking % 10 and / 10, which gives us the decimal value in reverse order. This requires an array since we need to print it out in the correct order. The interviewer wasn't too pleased and asked me to give a solution which didn't need the array ].

1095


Why is c called "mother" language?

1294


show how link list can be used to repersent the following polynomial i) 5x+2

2313


Are there constructors in c?

1011


What is calloc malloc realloc in c?

1059


Explain what is the benefit of using #define to declare a constant?

1192


What is equivalent to ++i+++j?

1094


Which is best linux os?

1028


How can I remove the leading spaces from a string?

1170


Is a pointer a kind of array?

1184


What is the purpose of sprintf() function?

1131


Can I use base-2 constants (something like 0b101010)? Is there a printf format for binary?

1004