how to find a 5th bit is set in c program
Answers were Sorted based on User's Feedback
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 |
#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 |
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 |
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 |
what is differnence b/w macro & functions
Code for calculating square root without using library function, of math.h
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?
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
What are the advantages and disadvantages of a heap?
How can I avoid the abort, retry, fail messages?
what do u mean by Direct access files? then can u explain about Direct Access Files?
What is "Duff's Device"?
What is string function in c?
1234554321 1234 4321 123 321 12 21 1 1 12 21 123 321 1234 4321 1234554321