how to set Nth bit of variable by using MACRO
Answer Posted / vikram
The above code is wrong it should be n-1 instead of n.
#include<stdio.h>
#define SET(val,n) (val|=1<<(n-1))
main()
{
int n = 256;
printf("%d",SET(n,1));
}
Is This Answer Correct ? | 13 Yes | 8 No |
Post New Answer View All Answers
Write a Program to find whether the given number or string is palindrome.
What are 3 types of structures?
write a program fibonacci series and palindrome program in c
What is unary operator?
What are the functions to open and close the file in c language?
Explain what are compound statements?
What is far pointer in c?
What are the advantages of union?
Write a c program to build a heap method using Pointer to function and pointer to structure ?
How can I read a binary data file properly?
What is identifier in c?
How can I recover the file name given an open stream or file descriptor?
Explain b+ tree?
In which layer of the network datastructure format change is done
stripos — Find position of first occurrence of a case- insensitive string int stripos ( char* haystack, char* needle, int offset ) Returns the numeric position of the first occurrence of needle in the haystack string. Note that the needle may be a string of one or more characters. If needle is not found, stripos() will return -1. The function should not make use of any C library function calls.