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

Is flag a keyword in c?

682


which is an algorithm for sorting in a growing Lexicographic order

1398


Explain heap and queue.

590


What is the use of c language in real life?

531


What is the size of enum in bytes?

591






How can this be legal c?

655


What is the difference between #include and #include 'file' ?

607


What are header files in c programming?

658


A c program to display count values from 0 to 100 and flash each digit for a secong.reset the counter after it reaches 100.use for loop,. pls guys hepl me.. :(

1743


How will you find a duplicate number in a array without negating the nos ?

1649


What does & mean in scanf?

605


What language is windows 1.0 written?

576


Is it cc or c in a letter?

568


What is the difference between functions getch() and getche()?

624


Write a program for finding factorial of a number.

636