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 |
int *a[5] refers to
How to Throw some light on the splay trees?
There are 8 billiard balls, and one of them is slightly heavier, but the only way to tell was by putting it on a weighing scale against another. What's the fewest number of times you'd have to use the scale to find the heavier ball?
what is the most appropriate way to write a multi-statement macro?
What's the difference between constant char *p and char * constant p?
What does extern mean in a function declaration?
to print the salary of an employee according to follwing calculation: Allowances:HRA-20% of BASIC,DA-45% of BASIC,TA-10%. Deductions:EPF-8% of BASIC,LIC-Rs.200/-Prof.Tax:Rs.200/- create c language program?
Write a program to reverse a string.
0 Answers Global Logic, iNautix, TCS, Wipro,
What is the use of putchar function?
How do you define a function?
write a C code to reverse a string using a recursive function, without swapping or using an extra memory.
9 Answers Motorola, TCS, Wipro,
Write a Program to accept different goods with the number, price and date of purchase and display them