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 > Point Out Correct Statements - Discussion

Read more:

"We cannot solve our problems with the same thinking we used when we created them."
- Albert Einstein
4. 

Which of the following statements are correct about the program?

#include<stdio.h>

int main()
{
    unsigned int m[] = {0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80};
    unsigned char n, i;
    scanf("%d", &n);
    for(i=0; i<=7; i++)
    {
        if(n & m[i])
            printf("yes");
    }
    return 0;
}

[A]. It will put OFF all bits that are ON in the number n
[B]. It will test whether the individual bits of n are ON or OFF
[C]. It will put ON all bits that are OFF in the number n
[D]. It will report compilation errors in the if statement.

Answer: Option A

Explanation:

No answer description available for this question.


Neha said: (Wed, Sep 7, 2011 12:38:11 AM)    
 
Can anybody explain.

Subash said: (Sun, Sep 18, 2011 01:02:42 PM)    
 
I think & operator is for both off and (on or off).

Nitesh said: (Sat, Oct 15, 2011 05:51:33 PM)    
 
ox01= 0*16^1+1*16^0=1

Now( num & ox01 (i.e.1))==will check whthr LSB is set or not

Similarly
ox02 ,ox04,ox08 will check 2ndbit,3rd bit and 4th bit
and then ox10=1*16^1+0*16^0=16
i.e 10000 hence it will check for 5th bit and so on...
like ox80= 8*16^1+0*16^0=128
i.e 1000 0000 it will check for 8th bit..

So code will check set bit upto 8 bit...

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!