C MCQ set number 00691

1. What is the type of the below assignment expression if x is of type float, y is of type int?
     y = x + y;
a) int
b) float
c) there is no type for an assignment expression
d) double

Answer

Answer: a [Reason:] None.

2. What is the value of the below assignment expression
     (x = foo())!= 1 considering foo() returns 2
a) 2
b) True
c) 1
d) 0

Answer

Answer: a [Reason:] None.

3. Operation “a = a * b + a” can also be written as:
a) a *= b + 1;
b) (c = a * b)!=(a = c + a);
c) a = (b + 1)* a;
d) All of the mentioned

Answer

Answer: d [Reason:] None.

4. for c = 2, value of c after c <<= 1;
a) c = 1;
b) c = 2;
c) c = 3;
d) c = 4;

Answer

Answer: d [Reason:] None.

5. What is the output of this C code?

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

a) 1 1
b) 1 2
c) 2 1
d) 2 2

Answer

Answer: c [Reason:] None.

6. What is the output of this C code?

  1.     #include <stdio.h>
  2.     int main()
  3.     {
  4.         int a = 4, n, i, result = 0;
  5.         scanf("%d", n);
  6.         for (i = 0;i < n; i++)
  7.         result += a;
  8.     }

a) Addition of a and n
b) Subtraction of a and n
c) Multiplication of a and n
d) Division of a and n

Answer

Answer: c [Reason:] None.

7. Which of the following is an invalid assignment operator?
a) a %= 10;
b) a /= 10;
c) a |= 10;
d) None of the mentioned

Answer

Answer: d [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.