Booleans

1

Evaluate the following
(false && true) || false || true

A. 0
B. 1
C. false
D. none of the mentioned

2

What is the value of p?

  
1.
    #include 
2.    
    using namespace std;
3.
    int main()
4.    
    {
5.    
        int p;
6.        
        bool a = true;
7.        
        bool b = false;
8.        
        int x = 10;
9.        
        int y = 5;
10.        
        p = ((x | y) + (a + b));
11.        
        cout << p;
12.        
        return 0;
13.
    }
A. 0
B. 16
C. 12
D. 2

3

What is the output of the following program?

 
1.
 #include 
2.
    using namespace std;
3.
    int f(int p, int q)
4.    
    {
5.
        if (p > q)
6.        
            return p;
7.            
        else
8.        
            return q;
9.            
    }
10.    
    main()
11.    
    {
12.    
        int a = 5, b = 10;
13.        
        int k;
14.        
        bool x = true;
15.        
        bool y = f(a, b);
16.        
        k =((a * b) + (x + y));
17.        
        cout << k;
18.        
    }
A. 55
B. 62
C. 52
D. none of the mentioned

4

Which of the two operators ++ and - work for the bool datatype in C++?

A. None
B. ++
C. -
D. Both

5

For what values of the expression is an if-statement block not executed?

A. 0 and all negative values
B. 0 and -1
C. 0
D. 0, all negative values, all positive values except 1