BreakInterview

1. Predict the output of the following code.
#include 
 
int main()
{
    int i = 1024;
    for (; i; i >>= 1)
        printf("BreakInterview");
    return 0;
}

10
11
9
Compiler Error

2. Predict the output of the following code.
#include
int main()
{
    int arr[5];
    // Assume that base address of arr is 2000 and size of integer
        // is 32 bit
    arr++;
    printf("%u", arr);
     return 0;
}

2004
2002
2020
lvalue required

3. Predict the output of the following code
#include
int main()
{
   printf("%c\n", ~('C' * -1));
   return 0;
}

A
B
C
Compiler Error

4. Pick the best statement for the below program:
#include "stdio.h"
 
int main()
{
 struct {int a[2];} arr[] = {{1},{2}};
 
 printf("%d %d %d %d",arr[0].a[0],arr[0].a[1],arr[1].a[0],arr[1].a[1]);
 
 return 0;
}

Compile error because arr has been defined using struct type incorrectly. First struct type should be defined using tag and then arr should be defined using that tag.
Compile error because apart from definition of arr, another issue is in the initialization of array of struct i.e. arr[].
No compile error and it’ll print 1 2 0 0
No compile error and it’ll print 1 0 2 0

5. Predict the output of the following code.
#include
int main()
{
    printf("%c ", "BreakInterview"[5]);
    return 0;
}

k
I
Compiler Error
Runtime Error

6. Predict the output of the following code.
#include 
int main()
{
    int i = 3;
    printf("%d %d %d", i++, i++, i++);
    return 0;
}

5 4 3
3 4 5
5 5 5
Compiler Dependent

7. Which of the following operators can be applied on structure variables?

Assignment Operator(=)
Equality Comparison (==)
Both of the above
None of the above

8. Predict the output of the following code.
#include 
    void main()
    {
        int a = 5, b = -7, c = 0, d;
        d = ++a && ++b || ++c;
        printf("%d%d%d%d", a, b, c, d);
    }

6 -6 0 0
6 -5 0 1
-6 -6 0 1
6 -6 0 1

9. What is the output of this C code?
#include 
    int main()
    {
        int x = 2;
        x = x << 1;
        printf("%d", x);
    }

4
1
Compiler Dependent
Depends on the endianness of the machine

10. Predict the output of the following code.
#include 
    int main()
    {
        int y = 1;
        if (y & (y = 2))
            printf("true %d", y);
        else
            printf("false %d", y);
     }

true 2
false 2
Either option a or option b
true 1