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 |
Take an MxN matrice from user and then sum upper diagonal in a variable and lower diagonal in a separate variables. Print the result
main() { clrscr(); } clrscr();
What is 'bus error'?
What is the use of function in c?
What are the types of assignment statements?
#define PRINT(int) printf("int = %d ",int) main() {< BR> intx,y,z; x=03;y=02;z=01; PRINT(x^x); z<<=3;PRINT(x); y>>=3;PRINT(y); }
Explain spaghetti programming?
find largest of 3 no
Write a programm such that if user enter 11.25 it roundup to 11 but if user enter 11.51 upto 11.99 it will round up to 12 i.e.;convert the floting point value into integer format as explain above..
Write the following function in C. stripos — Find position of first occurrence of a case- insensitive string int stripos ( char* haystack, char* needle, int offset ) Returns the numeric position of the first occurrence of needle in the haystack string. Note that the needle may be a string of one or more characters. If needle is not found, stripos() will return - 1. The function should not make use of any C library function calls.
3 Answers Google, Infosys, JTL, OpenFeel,
Expand the following LKB BKL FFG
typedef enum { html, java, javascript, perl, cgi } lang;The above statement defines a : a) Union b) User defined type c) Enumerated variable d) none