how to find a 5th bit is set in c program

Answer Posted / santhi perumal

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

int main()
{
int number;
int position;
int result;

printf("Enter the Number\n");
scanf("%d",&number);
printf("Enter the Position\n");
scanf("%d",&position);

result = (number >>(position-1));

if(result & 1)
printf("Bit is Set");
else
printf("Bit is Not Set");
}

Is This Answer Correct ?    18 Yes 7 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Write a program to use switch statement.

859


What is sizeof in c?

754


Explain can static variables be declared in a header file?

884


How pointer is different from array?

805


What are the header files used in c language?

770


what is the c source code for the below output? 10 10 10 10 10 10 10 10 10 10 9 9 7 6 6 6 6 6 6 9 7 5 9 7 3 2 2 5 9 7 3 1 5 9 7 3 5 9 7 4 4 4 4 5 9 7 8 8 8 8 8 8 8 8 9

1616


What is an identifier?

791


Do pointers store the address of value or the actual value of a variable?

808


What is the sizeof () operator?

782


Is stack a keyword in c?

821


How do I read the arrow keys? What about function keys?

827


What is variable declaration and definition in c?

688


What is the code in while loop that returns the output of given code?

1630


What functions are in conio h?

873


When is a “switch” statement preferable over an “if” statement?

847