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

Array is an lvalue or not?

843


Is c a great language, or what?

844


Write a program to check prime number in c programming?

809


How can I split up a string into whitespace-separated fields?

796


What does emoji p mean?

786


What is the purpose of main() function?

926


Which is best book for data structures in c?

814


void main(int n) { if(n==0) return; main(--n); printf("%d ",n); getch(); } how it work and what will be its output...............it any one know ans plz reply

2502


Why isn't any of this standardized in c? Any real program has to do some of these things.

917


what is stack , heap ,code segment,and data segment

2428


What is the main difference between calloc () and malloc ()?

829


will u please send me the placement papers to my mail???????????????????

1611


How do you use a 'Local Block'?

917


How can I write a function that takes a format string and a variable number of arguments?

824


Write a C++ program to generate 10 integer numbers between - 1000 and 1000, then store the summation of the odd positive numbers in variable call it sum_pos, then find the maximum digit in this variable regardless of its digits length.

1759