Toggle nth bit in a given integer - num

Answer Posted / sanyam jain

#include<stdio.h>
int main()
{
int a,b;
printf("Enter the number to be flipped\n");
scanf("%d",&a);
printf("Enter which bit to be flipped: ");
scanf("%d",&b);

a = a^(1<<(b-1));
printf("Resultan number is %d\n",a);
}

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 far and near ?

689


Where local variables are stored in c?

558


What are the disadvantages of a shell structure?

697


How can you be sure that a program follows the ANSI C standard?

1133


‘SAVEPOINT’ and ‘ROLLBACK’ is used in oracle database to secure the data comment. Give suitable examples of each with sql command.

1881






What is hash table in c?

576


How is = symbol different from == symbol in c programming?

616


What is pointer & why it is used?

607


What is int main () in c?

630


What does void main () mean?

738


What kind of structure is a house?

562


how many errors in c explain deply

1633


Does c have enums?

604


Is there any data type in c with variable size?

636


What is d scanf?

597