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

code for quick sort?

1985


what is the difference between north western polytechnique university and your applied colleges?? please give ur answers for this. :)

2345


What is c standard library?

1146


Why does everyone say not to use gets?

1027


What is the difference between array_name and &array_name?

1240


What does p mean in physics?

989


What library is sizeof in c?

1036


I was asked to write a program in c which when executed displays how many no.of clients are connected to the server.

2318


main(){char *str;scanf("%s",str);printf("%s",str); }The error in the above program is: a) Variable 'str' is not initialised b) Format control for a string is not %s c) Parameter to scanf is passed by value. It should be an address d) none

1302


What is a double c?

942


Explain what are its uses in c programming?

1015


What is double pointer in c?

984


Define Spanning-Tree Protocol (STP)

1071


What are the scope of static variables?

1117


Why is c called a structured programming language?

1214