Toggle nth bit in a given integer - num

Answer Posted / banavathvishnu

#include<stdio.h>
#include<conio.h>


Togglebit(int k,int bit)
{
printf("after %d bit is toggled = %d",bit,(k^(1<<(bit-
1))));
return 1;

}
int main()
{
int i;
int bitno;
printf("enter the number \n");
scanf("%d",&i);
printf("enter the bit number to toggle \n");
scanf("%d",&bitno);
Togglebit(i,bitno);
getch();


return 1;
}

Is This Answer Correct ?    1 Yes 4 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What will the code below print when it is executed?   int x = 3, y = 4;         if (x = 4)                 y = 5;         else                 y = 2;         printf ("x=%d, y=%d ",x,y);

1354


Explain what does the characters 'r' and 'w' mean when writing programs that will make use of files?

751


Why we use stdio h in c?

575


How can I write functions that take a variable number of arguments?

624


write a program to convert a expression in polish notation(postfix) to inline(normal) something like make 723+* (2+3) x 7 (not sure) just check out its mainly printing expression in postfix form to infix.

2264






a sequence of bytes with one to one corrspondence to those in the external device a) sequential addressing b) address c) byte code d) none

717


How old is c programming language?

573


What is the difference between far and near in c?

599


How is a null pointer different from a dangling pointer?

555


What are run-time errors?

598


What could possibly be the problem if a valid function name such as tolower() is being reported by the C compiler as undefined?

744


What is an lvalue?

634


What is the time and space complexities of merge sort and when is it preferred over quick sort?

674


What is pointer to pointer in c with example?

544


i have to apply for rbi before that i need to know the the syllabus for the entrance questions. whethet it may be aps or techinical

1837