C MCQ set number 00685

1. Are logical operators sequence points?
a) True
b) False
c) Depends on the compiler
d) Depends on the standard

Answer

Answer: a [Reason:] None.

2. Does logical operators in C language are evaluated with short circuit?
a) True
b) False
c) Depends on the compiler
d) Depends on the standard

Answer

Answer: a [Reason:] None.

3. Result of a logical or relational expression in C is
a) True or False
b) 0 or 1
c) 0 if expression is false and any positive number if expression is true
d) None of the mentioned

Answer

Answer: b [Reason:] None.

4. What will be the value of d in the following program?

  1.     #include <stdio.h>
  2.     int main()
  3.     {
  4.         int a = 10, b = 5, c = 5;
  5.         int d;
  6.         d = b + c == a;
  7.         printf("%d", d);
  8.     }

a) Syntax error
b) 1
c) 5
d) 10

Answer

Answer: b [Reason:] None.

5. What is the output of this C code?

  1.     #include <stdio.h>
  2.     int main()
  3.     {
  4.         int a = 10, b = 5, c = 3;
  5.         b != !a;
  6.         c = !!a;
  7.         printf("%dt%d", b, c);
  8.     }

a) 5 1
b) 0 3
c) 5 3
d) 1 1

Answer

Answer: a [Reason:] None.

6. Which among the following is NOT a logical or relational operator?
a) !=
b) ==
c) ||
d) =

Answer

Answer: d [Reason:] None.

7. What is the output of this C code?

  1.     #include <stdio.h>
  2.     int main()
  3.     {
  4.         int a = 10;
  5.         if (a == a--)
  6.             printf("TRUE 1t");
  7.         a = 10;
  8.         if (a == --a)
  9.             printf("TRUE 2t");
  10.     }

a) TRUE 1
b) TRUE 2
c) TRUE 1 TRUE 2
d) Compiler Dependent

Answer

Answer: d [Reason:] This is a sequence point problem and hence the result will be implementation dependent

8. Relational operators cannot be used on:
a) structure
b) long
c) strings
d) float

Answer

Answer: a [Reason:] None.

ed010d383e1f191bdb025d5985cc03fc?s=120&d=mm&r=g

DistPub Team

Distance Publisher (DistPub.com) provide project writing help from year 2007 and provide writing and editing help to hundreds student every year.