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 are qualifiers and modifiers c?

959


What is a class c rental property?

1062


Describe the modifier in c?

1070


What are the rules for identifiers in c?

1041


Explain main function in c?

1057


How are pointers declared in c?

1019


What is your stream meaning?

1151


What is default value of global variable in c?

954


There is a practice in coding to keep some code blocks in comment symbols than delete it when debugging. How this affect when debugging?

1257


Can you please explain the difference between strcpy() and memcpy() function?

1029


What is the equivalent code of the following statement in WHILE LOOP format?

1261


Can the “if” function be used in comparing strings?

998


What is a file descriptor in c?

1071


What are the advantage of c language?

1022


What is the purpose of the following code? Is there any problem with the code? void send(int count, short *to, short *from) { /* count > 0 assumed */ register n = (count + 7) / 8; switch (count % 8) { case 0: do { *to = *from++; case 7: *to = *from++; case 6: *to = *from++; case 5: *to = *from++; case 4: *to = *from++; case 3: *to = *from++; case 2: *to = *from++; case 1: *to = *from++; } while (--n > 0); } }

2452