C Programming MCQs - Precedence And Order Of Evaluation

This section focuses on the "Precedence And Order Of Evaluation" in C programming. These Multiple Choice Questions (MCQ) should be practiced to improve the C programming skills required for various interviews (campus interview, walk-in interview, company interview), placement, entrance exam and other competitive examinations.

1. In expression i = g() + f(), first function called depends on __________

A. Compiler
B. Associativiy of () operator
C. Precedence of () and + operator
D. Left to write of the expression

View Answer


2. Which of the following is correct Associativity for == operator?

A. Left to right
B. Right to left
C. Left to left
D. Right to right

View Answer


3. Which of the following operator has highest Precedence?

A. *
B. /
C. ~
D. []

View Answer


4. Which of the following operator has lowest Precedence?

A. ||
B. ,
C. ?:
D. =

View Answer


5. Which of the following is a ternary operator?

A. ||
B. &&
C. ?:
D. >>

View Answer


6. What will be output for the following code?

#include <stdio.h>
int main()
{
    int a = 1, b = 2;
    int c = a ^ b & 1;
    printf(""%d
"", c);
}

A. 0
B. 1
C. 2
D. 3

View Answer


7. What will be output for the following code?

#include <stdio.h>
int main()
{
    double a = 5 % 3 & 4 + 5 * 6;
    printf(""%lf"", a);

}

A. 2
B. 30
C. (2.000000
D. Run-time error

View Answer


8. What will be output for the following code?

#include <stdio.h>
int main()
{
        int a = 2;
        int b = (a++, a++);
        printf(""%d%d
"", b, a);
}

A. 3 4
B. 4 4
C. 3 5
D. 2 4

View Answer


9. Which of the following has same Precedence?
A. ++
B. ->
C. !

A. A and B
B. B and C
C. A and C
D. All has same Precedence

View Answer


10. Which of the following option is the correct representation of the following C statement?

e = a * b + c / d * f;

A. e = (a * (b +(c /(d * f))));
B. e = ((a * b) + (c / (d * f)));
C. e = ((a * b) + ((c / d)* f));
D. Both C and B

View Answer






Discussion


* You must be logged in to add comment.