how to set Nth bit of variable by using MACRO

Answer Posted / kirankumaryakkala

#define set(val,n) val|=1<<n //do left-shift then bitwise OR

logic is val|=1<<n
means,
first shift the value 1 to ntimes and do the bitwise or with
value.
u will get the answer

Is This Answer Correct ?    30 Yes 6 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

When can you use a pointer with a function?

568


Write a program to maintain student’s record. Record should not be available to any unauthorized user. There are three (3) categories of users. Each user has its own type. It depends upon user’s type that which kind of operations user can perform. Their types and options are mentioned below: 1. Admin (Search Record [by Reg. No or Name], View All Records, Insert New Record, Modify Existing Record) 2. Super Admin (Search Record [by Reg. No or Name], View All Records, Insert New Record, Modify Existing Record, Delete Single Record) 3. Guest (Search Record [by Reg. No or Name], View All Records) When first time program runs, it asks to create accounts. Each user type has only 1 account (which means that there can be maximum 3 accounts). In account creation, following options are required: Login Name: <6-10 alphabets long, should be unique> Password: <6-10 alphabets long, should not display characters when user type> Confirm Password: Account Type: Login Name, Password and Account Type should be stored in a separate file in encrypted form. (Encryption means that actual information should be changed and Decryption means that Encrypted information is changed back to the actual information) If any of the above mentioned requirement(s) does not meet then point out mistake and ask user to specify information again. When Program is launched with already created accounts, it will ask for user name and password to authenticate. On successful authentication, give options according to the user’s type.

1513


Explain threaded binary trees?

681


What is an expression?

658


Write a function expand(s1,s2) that expands shorthand notations like a-z in the string s1 into the equivalent complete list abc...xyz in s2 . Allow for letters of either case and digits, and be prepared to handle cases like a-b-c and a-z0-9 and -a-z. z-a:zyx......ba -1-6-:-123456- 1-9-1:123456789987654321 a-R-L:a-R...L a-b-c:abbc

5056






What is main function in c?

551


Write a C/C++ program to add a user to MySQL. The user should be permitted to only "INSERT" into the given database.

1497


What do you mean by scope of a variable in c?

544


how can f be used for both float and double arguments in printf? Are not they different types?

610


what are enumerations in C

724


Why is not a pointer null after calling free? How unsafe is it to use (assign, compare) a pointer value after it is been freed?

603


How can I generate floating-point random numbers?

608


How can I change their mode to binary?

698


what are the 10 different models of writing an addition program in C language?

1439


What are the rules for the identifier?

671