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

List a few unconditional control statement in c.

564


What is an auto keyword in c?

652


Tell us two differences between new () and malloc ()?

617


write a c program to calculate sum of digits till it reduces to a single digit using recursion

2728


What are file streams?

574






What is scanf_s in c?

640


Write a code to generate divisors of an integer?

647


What is a far pointer in c?

603


Explain how can I open a file so that other programs can update it at the same time?

599


Explain how do you list files in a directory?

620


What is the difference between %d and %i?

602


what are # pragma staments?

1634


what is the height of tree if leaf node is at level 3. please explain

1606


Are c and c++ the same?

635


What is scope rule in c?

610