write a c program to check weather a particluar bit is set
or not?

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 ?    33 Yes 12 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Write a C program to count the number of email on text

1411


Can you pass an entire structure to functions?

686


Using functions, write a program that multiplies two arrays. Use the following functions: - Function ReadArray - Function MultiplyArrays - Function DisplayArrays

1881


Who is the main contributor in designing the c language after dennis ritchie?

541


How do we open a binary file in Read/Write mode in C?

671






Difference between constant pointer and pointer to a constant.

605


What is static volatile in c?

568


What is the most efficient way to store flag values?

678


Do string constants represent numerical values?

907


Explain is it better to use a pointer to navigate an array of values, or is it better to use a subscripted array name?

663


What is page thrashing?

646


How do we make a global variable accessible across files? Explain the extern keyword?

1413


State the difference between realloc and free.

620


Write a program to swap two numbers without using third variable in c?

607


Can you subtract pointers from each other? Why would you?

552