Toggle nth bit in a given integer - num
Answers were Sorted based on User's Feedback
Answer / 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 |
Answer / 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 |
when will be evaluated as true/ if(x==x==x) a) x=1; b) x=0; c) x=-1; d) none
How can I get random integers in a certain range?
could u able to tell about suresoft technical session
What is the difference between union and anonymous union?
A character flag or control mechanism that delineates one data item from another a) variable b) constant c) delimiter d) call by reference
print out of string in this format; 1. "rajesh" 2. \n 3. %d
what is the Output? int a=4 b=3; printf("%d%d%d%d%d%d",a++,++a,a++,a++,++a,a++); printf("%d%d%d%d%d%d",b--,b--,--b,b--,--b,--b);
in a town the percentage of men is 52 the percentage of total literacy is 48 if total percentage of literate men is 35 of the total population write a program to find the total no of the literate men and women if the population of the town is 80000
Why malloc is faster than calloc?
Write a program that takes a 5 digit number and calculates 2 power that number and prints it.
Differentiate Source Codes from Object Codes
Add 2 64 bit numbers on a 32 bit machine
3 Answers EMC, Hyderabad Central University, NetApp,