IndiaBIX.com
Arithmetic Aptitude Data Interpretation
Logical Reasoning Verbal Reasoning Non Verbal Reasoning
General Knowledge
Sudoku Number puzzles Missing letters puzzles Logical puzzles Playing cards puzzles Clock puzzles
C Programming C# Programming Java Programming
Networking Database Questions Computer Science Basic Electronics Digital Electronics Electronic Devices Circuit Simulation Electrical Enigneering Engineering Mechanics Technical Drawing
Placement Papers Group Disucssion HR Interview Technical Interview Body Language
Aptitude Test Verbal Ability Test Verbal Reasoning Test Logical Reasoning Test C Programming Test Java Programming Test Data Interpretation Test General Knowledge Test
Data Structures Operating Systems Networking DATABASE Database Basics SQL Server Basics SQL Server Advanced SQL Server 2008 JAVA Core Java Java Basics Advanced Java UNIX Unix File Management Unix Memory Management Unix Process Managemnt C Interview Questions The C Language Basics .NET Interview Questions .NET Framework ADO.NET ASP.NET Software Testing

C Programming - Bitwise Operators - Discussion

@ : Home > C Programming > Bitwise Operators > General Questions - Discussion

Read more:

"Two things are infinite: the universe and human stupidity; and I'm not sure about the universe."
- Albert Einstein
2. 

Which bitwise operator is suitable for turning off a particular bit in a number?

[A]. && operator[B]. & operator
[C]. || operator[D]. ! operator

Answer: Option E

Explanation:

No answer description available for this question.


Ravi(Bit Mesra Cse_2K7) said: (Thu, Oct 21, 2010 12:03:39 AM)    
 
Any bit AND(&) with 0 will give a zero .i.e. will turn that particular bit OFF.

Suhas . U said: (Fri, Nov 26, 2010 11:07:31 AM)    
 
Which bit u want make 0 ...make only that bit 0 n allother bits 1...
ex:-to make 3rd bit 0 use &operator with one operand as11110111

Arjun Prasad said: (Mon, Feb 28, 2011 08:15:33 AM)    
 
To make above operand you take a number 1 and then shift its only set bit to the number of the bit you want to turn off(1<<3) and then take AND with given number.

Arjun Prasad said: (Mon, Feb 28, 2011 08:18:20 AM)    
 
~(1<<"bit position") is the operand

Sohan Lal Mits Gwalior said: (Tue, Mar 1, 2011 09:25:40 AM)    
 
Bitwise 'AND' of any bit with zero bit is always zero (off).

Kumar said: (Sat, Apr 23, 2011 10:26:30 PM)    
 
Could anyone give an explanation in brief with example the above examples could not be understood

Sundar said: (Sun, Apr 24, 2011 08:01:55 AM)    
 
@Kumar

Let me explain.

How to turn off only the 4th bit (from right) in a 16-bit binary number?

unsigned int intFalg4Off = 0xfff7;
//Hex = 0xfff7 (or) Decimal = 65527 (or) Binay = 11111111 11110111

unsigned int intInputVal = 255;
//Decimal = 255 (or) 0x00ff (or) 00000000 11111111

unsigned int Result = intInputVal & intFalg4Off;

The result will be the & (AND operation) between the binary numbers given below :

11111111 11110111
00000000 11111111
00000000 11110111 (Decimal = 247 or Hex = 0x00f7)

Here 4th bit of the given input has been turned off. Therefore, intResult will contain the value 247.

Hope this will help you. Have a nice day!

Ramya said: (Fri, Jul 8, 2011 11:41:41 AM)    
 
Thanks sundar.

Anuradha Sharma said: (Fri, Sep 2, 2011 05:46:06 PM)    
 
If we take any bit AND (&) with 0 will give a zero. (i.e) Will turn that particular bit OFF.

Saurav said: (Mon, Sep 5, 2011 12:26:55 AM)    
 
But! why will && not work?

Heena said: (Fri, Sep 16, 2011 11:08:01 PM)    
 
Because && is a logical operator not a bitwise (bitwise is a operator that takes single bit at a time).

Bari said: (Thu, Sep 22, 2011 08:05:55 PM)    
 
Please explain about bitwise operator?

Bari said: (Thu, Sep 22, 2011 08:08:14 PM)    
 
How to work bitwise ?

Vinod Basi said: (Fri, Nov 4, 2011 10:01:33 PM)    
 
Sorry, I know this is an outdated thread... But just saw Mr.Gaurav's doubt to be one which I had a days back.
Here is a simple explanation, correct me if am wrong.

@Saurav

Its like && and || are logical operators, evaluting true statements.
Eg:
Sachin && Sehwag opens batting, It returns true(1) only if both the guys are present to open the game. Else False(0)

Sachin || Sehwag, return true(1), if either Sachin or Sehwag accompanied by someone else opens the game. Else false(0)

& and | are bitwise operators, High and Low
AND, OR gates truth table pretty much explains it.
Eg:
2 & 3 (AND)
010
&
011
------
010

2 | 3 (OR)
010
|
011
------
011

Bitwise operators can be predominantely found in Embedded design, to find the status (ON or OFF) of a bit in a system.


Hope this explains...

Cheers...

Athi said: (Tue, Nov 29, 2011 08:44:18 AM)    
 
I have 1 doubt please tell me how to find the status of a bit ie char s[50];

Then write a c program to find the status of 170th bit.

Satyaprakash said: (Thu, Jan 12, 2012 11:52:47 AM)    
 
Turn off operator in bitwise operators is and because it turns 1&0 and 0&1 into turn off(that is o). |(OR) bitwise turns preceeded operations into turn on(that is 1).

Hence AND IS turn off operator.

Naveen Kumar Ramisetty said: (Thu, Feb 2, 2012 11:18:12 PM)    
 
Thanks ramya.

Write your comments here:
Name *:     Email:


© 2008-2011 by IndiaBIX™ Technologies. All Rights Reserved | Copyright | Terms of Use & Privacy Policy

Advertise     Contact us: info@indiabix.com     Follow us on twitter!