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's wrong with the call "fopen ("c:\newdir\file.dat", "r")"?

1 Answers  


Is c language still used?

0 Answers  


DIFFERNCE BETWEEN THE C++ AND C LANGUAGE?

2 Answers   Wipro,


Design a program using an array that lists even numbers and odd numbers separately from the 12 numbers supplied by a user.

8 Answers  


how could explain about job profile

0 Answers  






In c programming language, how many parameters can be passed to a function ?

0 Answers  


how many keywords are available in 'c' language a) 32 b) 34 c) 45 d) 48

1 Answers  


20. main() { int i=5; printf("%d%d%d%d%d%d",i++,i--,++i,--i,i); } Answer:??????

2 Answers  


What is the concatenation operator?

0 Answers  


What is the use of bit field?

0 Answers  


how does the C compiler interpret the following two statements p=p+x; q=q+y; a.p=p+x; q=q+y b.p=p+xq=q+y c.p=p+xq; q=q+y d.p=p+x/q=q+y

4 Answers   TCS,


What is the output of the below program and how it is? void main() { static int var=5; printf("%d",var--); if(var) main(); }

8 Answers   MindFire, TCS, Tech Mahindra,


Categories