ALLInterview.com :: Home Page KalAajKal.com
 Advertise your Business Here     
Browse  |   Placement Papers  |   Company  |   Code Snippets  |   Certifications  |   Visa Questions
Post Question  |   Post Answer  |   My Panel  |   Search  |   Articles  |   Topics  |   ERRORS new
   Refer this Site  Refer This Site to Your Friends  Site Map  Bookmark this Site  Set it as your HomePage  Contact Us     Login  |  Sign Up                      
tip   To Refer this Site to Your Friends   Click Here
Google
 
Categories  >>  Software  >>  Programming Languages  >>  C
 
 


 

 
 C interview questions  C Interview Questions
 C++ interview questions  C++ Interview Questions
 VC++ interview questions  VC++ Interview Questions
 Delphi interview questions  Delphi Interview Questions
 Programming Languages AllOther interview questions  Programming Languages AllOther Interview Questions
Question
write a c program to check weather a particluar bit is set 
or not?
 Question Submitted By :: Anilkumar
I also faced this Question!!     Rank Answer Posted By  
 
  Re: write a c program to check weather a particluar bit is set or not?
Answer
# 1
#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 ?    4 Yes 1 No
Santhi Perumal
 
  Re: write a c program to check weather a particluar bit is set or not?
Answer
# 2
#include <stdio.h>

int main ()
{
	int variable = 6;
	int position = 3;
	char array [2][10] = {"NOT SET", "SET"};
	
	// check the wheather the second bit is set
	printf  ( "\n The bit is %s", 
			array [ ( variable & ( 1 << ( 
position - 1 ) ) ) / position ] );
	return ( 0 );
}
 
Is This Answer Correct ?    0 Yes 0 No
Abdur Rab
 
 
 
  Re: write a c program to check weather a particluar bit is set or not?
Answer
# 3
#include<stdio.h>
#include<conio.h>
void main()
{
int m,n,o,p;
printf("enter the number :");
scanf("%d",&m);
printf("enter the bit position for checking it is set or reset :");
scanf("%d",&n);
o=m;
p=o>>(n-1);
p=p&1;
if(p==1)
printf("the bit is set");
else 
printf("the bit is reset");
getch();
}

thank u
 
Is This Answer Correct ?    0 Yes 0 No
Vignesh1988i
 
  Re: write a c program to check weather a particluar bit is set or not?
Answer
# 4
#include<stdio.h>
main()
{
     int n,p;
     printf("enter number");
     scanf("%d",&n);
     printf("enter the position");
     scanf("%d",&p);
     if(n&(1<<p))
       printf("the bit is set");
     else
       printf("the bit is clear");
}
 
Is This Answer Correct ?    0 Yes 0 No
Valli
 

 
 
 
Other C Interview Questions
 
  Question Asked @ Answers
 
can we write a program in c for printf and scanf without using header file stdio.h  1
wite a programme in c to linear search a data using flag and without using flags? TCS3
int arr[] = {1,2,3,4} int *ptr=arr; *(arr+3) = *++ptr + *ptr++; Final contents of arr[] Hughes4
What are .h files and what should I put in them?  3
if ENTERED FIVE DIGITS DESIGN A PROGRAM THAT WILL FIND CORRESPONDING VALUE FROM ASCII TABLE  1
What is the output of following program ? int main() { int x = 5; printf("%d %d %d\n", x, x << 2, x >> 2); } Qualcomm3
What is a class?  2
how memory store byte Huawei3
Write a C program to print 1 2 3 ... 100 without using loops?  5
Write a c code segment using a for loop that calculates and prints the sum of the even integers from 2 to 30, inclusive?  2
program to find a smallest number in an array Microsoft5
WRITE A C PROGRAM TO FIND SECOND BIGGEST VALUE FROM THE GIVEN VALUES  1
2. What is the function of ceil(X) defined in math.h do? A)It returns the value rounded down to the next lower integer B)it returns the value rounded up to the next higher integer C)the Next Higher Value D)the next lower value Accenture2
An interactive c program to read basic salary of 15 persons. each person gets 25% of basic as HRA, 15%of basic as conveyance allowances, 10%of basic as entertainment allowances.The total salary is calculated by adding basic+HRA+CA+EA.Calculate how many out of 15 get salary above 10,000.Rs also print the salary of each employee  2
Difference Between embedded software and soft ware? Bosch1
write a c program to accept a given integer value and print its value in words  3
how we can make 3d venturing graphics on outer interface Microsoft1
what is meant by the "equivalence of pointers and arrays" in C? Satyam3
52.write a “Hello World” program in “c” without using a semicolon? 53.Give a method to count the number of ones in a 32 bit number? 54.write a program that print itself even if the source file is deleted? 55.Given an unsigned integer, find if the number is power of 2?  6
what is the diff b/w static and non static variables in C. Give some examples plz. Wipro2
 
For more C Interview Questions Click Here 
 
 
 
 
 
   
Copyright Policy  |  Terms of Service  |  Help  |  Site Map 1  |  Articles  |  Site Map  |   Site Map  |  Contact Us interview questions urls   External Links 
   
Copyright © 2007  ALLInterview.com.  All Rights Reserved.

ALLInterview.com   ::  Forum9.com   ::  KalAajKal.com