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...

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


Please Help Members By Posting Answers For Below Questions

What was noalias and what ever happened to it?

1100


What is the most efficient way to store flag values?

1233


How do I get an accurate error status return from system on ms-dos?

1179


I need a sort of an approximate strcmp routine?

1081


What is a static variable in c?

1170


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?

1214


What is the basic structure of c?

1155


Is file a keyword in c?

987


How can I get back to the interactive keyboard if stdin is redirected?

1242


What is struct node in c?

1127


Explain pointer. What are function pointers in C?

1145


What is null in c?

1156


what is uses of .net

1788


What is the difference between malloc() and calloc() function in c language?

1140


What are the features of c languages?

1140