ExamVeda
Login
Home
71
What will be the final value of j in the following C code?
#include <stdio.h>
int main()
{
    int i = 0, j = 0;
    if (i && (j = i + 10))
        //do something
        ;
}
Discuss
Answer & Solution
Answer: Option A
No explanation is given for this question. Let's Discuss on Board
72
Will the following C code compile without any error?
#include <stdio.h>
int main()
{
    int k;
    {
        int k;
        for (k = 0; k < 10; k++);
    }
}
Discuss
Answer & Solution
Answer: Option A
No explanation is given for this question. Let's Discuss on Board
73
What will be the output of the following C code?
#include <stdio.h>
int main()
{
    int x = 0, y = 2;
    int z = ~x & y;
    printf("%d\n", z);
}
Discuss
Answer & Solution
Answer: Option B
Solution:
Understanding Bitwise Operators:
This question tests your understanding of bitwise operators in C. Let's break down the code step by step.

1. `~x`: The tilde (~) is the bitwise NOT operator. It flips all the bits of the variable `x`. Since `x` is 0 (which is represented as all 0s in binary), `~x` will become -1 (represented as all 1s in two's complement).

2. `&y`: The ampersand (&) is the bitwise AND operator. It compares the corresponding bits of two operands. If both bits are 1, the resulting bit is 1; otherwise, it's 0.

3. `~x & y`: We're performing a bitwise AND between `~x` (-1, all 1s) and `y` (2). Let's assume your system uses 32-bit integers (most do). Then 2 is represented as `00000000000000000000000000000010` in binary. The bitwise AND operation will be:
11111111111111111111111111111111 (&) 00000000000000000000000000000010 = 00000000000000000000000000000010
This results in 2.

4. `printf("%d\n", z);` This line prints the value of `z`, which is 2, to the console.

Therefore, the correct answer is B: 2
Important Note: The exact binary representation and the behavior of bitwise NOT might depend slightly on your specific compiler and system architecture, but the principle remains the same.
74
What will be the output of the following C code?
#include <stdio.h>
int main()
{
    int a = 4, n, i, result = 0;
    scanf("%d", &n);
    for (i = 0;i < n; i++)
    result += a;
}
Discuss
Answer & Solution
Answer: Option C
No explanation is given for this question. Let's Discuss on Board
75
What will be the output of the following C code?
#include<stdio.h>
enum hello
{
    a,b=99,c,d=-1
};
main()
{
    enum hello m;
    printf("%d\n%d\n%d\n%d\n",a,b,c,d);
}
Discuss
Answer & Solution
Answer: Option C
No explanation is given for this question. Let's Discuss on Board
76
What will be the output of the following C code?
#include <stdio.h>
int main()
{
    j = 10;
    printf("%d\n", j++);
    return 0;
}
Discuss
Answer & Solution
Answer: Option C
No explanation is given for this question. Let's Discuss on Board
77
What will be the output of the following C code?
#include <stdio.h>
#define MAX 2
enum bird {SPARROW = MAX + 1, PARROT = SPARROW + MAX};
int main()
{
    enum bird b = PARROT;
    printf("%d\n", b);
    return 0;
}
Discuss
Answer & Solution
Answer: Option B
No explanation is given for this question. Let's Discuss on Board
78
What will be the output of the following C code?
#include<stdio.h>
enum shyam
{
    a=2,b=3.56
};
enum shyam s;
main()
{
    printf("%d%d",a,b);
}
Discuss
Answer & Solution
Answer: Option D
No explanation is given for this question. Let's Discuss on Board
79
What will be the output of the following C code?
#include <stdio.h>
int main()
{
    int a[5] = {1, 2, 3, 4, 5};
    int i;
    for (i = 0; i < 5; i++)
        if ((char)a[i] == '5')
            printf("%d\n", a[i]);
        else
            printf("FAIL\n");
}
Discuss
Answer & Solution
Answer: Option D
No explanation is given for this question. Let's Discuss on Board
80
One of the major difference between typedef and #define is that typedef interpretation is performed by the . . . . . . . . whereas #define interpretation is performed by the . . . . . . . .
Discuss
Answer & Solution
Answer: Option C
No explanation is given for this question. Let's Discuss on Board