How we can set and clear bit in a byte using macro function?

Answer Posted / sunitha

take i=5;
print its binary value

now for setting a bit
i=i>>5|1;
this will set 5th bit in binary value of 5

now for clearing a bit
i=i>>5 xor 1
this will clear 5th bit in binary value of 5

Is This Answer Correct ?    6 Yes 3 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

what is the difference between class and unio?

1857


what is reason of your company position's in india no. 1.

1775


What are types of preprocessor in c?

617


I need previous papers of CSC.......plz help out by posting them.......

1816


How does sizeof know array size?

627






Explain zero based addressing.

608


Write a programme using structure that create a record of students. The user allow to add a record and delete a record and also show the records in ascending order.

1620


What are dangling pointers? How are dangling pointers different from memory leaks?

621


Explain what are binary trees?

611


What are local static variables? How can you use them?

645


What is && in c programming?

676


Why #include is used in c language?

596


If i have an array 0 to 99 i.e,(Size 100) I place the values 1 to 100 randomly like a[0]=29,a[1]=56 upto array[99].. the values are only between 1 to 100. getting the array values by using scanf.. If i entered one wrong element value line a[56]=108. how can i find it.. and also how to find the missing value in 1 to 100.. and i want to replace the missing values.. any one of them know please post your answer..

1591


How do I read the arrow keys? What about function keys?

612


which of the following is allowed in a "C" arithematic instruction a) [] b) {} c) () d) none of the above

1136