250+ TOP MCQs on Assignment Operators & Expressions and Answers

C aptitude questions on “Assignment Operators & Expressions”. One shall practice these aptitude questions to improve their C programming skills needed for various interviews (campus interviews, walkin interviews, company interviews), placements, entrance exams, aptitude tests and other competitive exams. These questions can be attempted by anyone focusing on learning C Programming language. They can be a beginner, fresher, engineering graduate or an experienced IT professional. Our C questions come with detailed explanation of the answers which helps in better understanding of C concepts.

Here is a listing of C aptitude questions on “Assignment Operators & Expressions” along with answers, explanations and/or solutions:

1. What will be the output of the following C code?

  1.     #include 
  2.     void main()
  3.     {
  4.         int x = 0;
  5.         if (x = 0)
  6.             printf("Its zeron");
  7.         else
  8.             printf("Its not zeron");
  9.     }

a) Its not zero
b) Its zero
c) Run time error
d) None
Answer: a
Clarification: None.

2. What will be the output of the following C code?

  1.     #include 
  2.     void main()
  3.     {
  4.         int k = 8;
  5.         int x = 0 == 1 && k++;
  6.         printf("%d%dn", x, k);
  7.     }

a) 0 9
b) 0 8
c) 1 8
d) 1 9
Answer: b
Clarification: None.

3. What will be the output of the following C code?

  1.     #include 
  2.     void main()
  3.     {
  4.         char a = 'a';
  5.         int x = (a % 10)++;
  6.         printf("%dn", x);
  7.     }

a) 6
b) Junk value
c) Compile time error
d) 7
Answer: c
Clarification: None.

4. What will be the output of the following C code snippet?

  1.     #include 
  2.     void main()
  3.     {
  4.         1 < 2 ? return 1: return 2;
  5.     }

a) returns 1
b) returns 2
c) Varies
d) Compile time error
Answer: d
Clarification: None.

5. What will be the output of the following C code snippet?

  1.     #include 
  2.     void main()
  3.     {
  4.         unsigned int x = -5;
  5.         printf("%d", x);
  6.     }

a) Run time error
b) Aries
c) -5
d) 5
Answer: c
Clarification: None.

6. What will be the output of the following C code?

  1.     #include 
  2.     int main()
  3.     {
  4.         int x = 2, y = 1;
  5.         x *= x + y;
  6.         printf("%dn", x);
  7.         return 0;
  8.     }

a) 5
b) 6
c) Undefined behaviour
d) Compile time error
Answer: b
Clarification: None.

7. What will be the output of the following C code?

  1.     #include 
  2.     int main()
  3.     {
  4.         int x = 2, y = 2;
  5.         x /= x / y;
  6.         printf("%dn", x);
  7.         return 0;
  8.     }

a) 2
b) 1
c) 0.5
d) Undefined behaviour
Answer: a
Clarification: None.

8. What will be the output of the following C code?

  1.     #include 
  2.     int main()
  3.     {
  4.         int x = 1, y = 0;
  5.         x &&= y;
  6.         printf("%dn", x);
  7.     }

a) Compile time error
b) 1
c) 0
d) Undefined behaviour
Answer: a
Clarification: None.

Leave a Reply

Your email address will not be published. Required fields are marked *