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

Answers were Sorted based on User's Feedback



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

Answer / valli

main()
{
int n;
printf("enter n:");
scanf("%d",&n);
if(n&(1<<5);
printf("5th bit in %d is set",n);
}

Is This Answer Correct ?    20 Yes 2 No

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

Answer / 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

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

Answer / rajkumar

#include<stdio.h>
void main()
{
int a;
a=a>>4;
if(a%2==1)
printf("the bit is set");
else
printf("the bit is not set");
}

Is This Answer Correct ?    9 Yes 3 No

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

Answer / sumit kumar

Take the input 5 from keyword :-
#include<stdio.h>
main()
{
int num,pos;
printf("enter the no.:");
scanf("%d",&num);
printf("enter the position:");
scanf("%d",&pos);
if(num & (1<<pos))
{
printf("pos is set");
}
else
{
printf("pos is not set");
}
}

Is This Answer Correct ?    3 Yes 0 No

Post New Answer

More C Interview Questions

what is differnence b/w macro & functions

1 Answers  


Code for calculating square root without using library function, of math.h

4 Answers   IBM,


write a c program to find the square of a 5 digit number and print the result.

5 Answers   Accenture, Sasken, Vimukti Technologies,


What are runtime error?

0 Answers  


Find string palindrome 10marks

5 Answers   Honeywell, Infosys, Riktam, Roland,






`write a program to display the recomended action depends on a color of trafic light using nested if statments

0 Answers  


What are the advantages and disadvantages of a heap?

0 Answers  


How can I avoid the abort, retry, fail messages?

0 Answers  


what do u mean by Direct access files? then can u explain about Direct Access Files?

0 Answers   LG Soft,


What is "Duff's Device"?

0 Answers   Celstream,


What is string function in c?

0 Answers  


1234554321 1234 4321 123 321 12 21 1 1 12 21 123 321 1234 4321 1234554321

0 Answers  


Categories