This set of C Multiple Choice Questions & Answers (MCQs) focuses on “Assignment Operators & Expressions – 2”.
Pre-requisite for this C MCQ set: Advanced C Programming Video Tutorial.
1. What is the type of the following assignment expression if x is of type float and y is of type int?
y = x + y;
c) there is no type for an assignment expression
2. What will be the value of the following C expression?
(x = foo()) != 1 considering foo() returns 2
Explanation: The C language sub-expression “x = foo()” will assign a value of 2 to the variable ‘x’. Then, it will check if this value is not equal to 1 which is true and hence the result will be 1.
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
4. What will be the final value of c in the following C statement? (Initial value: c = 2)
c <<= 1;
a) c = 1;
b) c = 2;
c) c = 3;
d) c = 4;
5. What will be the output of the following C code?
int a = 1, b = 2;
a += b -= a;
printf("%d %d", a, b);
a) 1 1
b) 1 2
c) 2 1
d) 2 2
6. What will be the output of the following C code?
int a = 4, n, i, result = 0;
for (i = 0;i < n; i++)
result += a;
a) Addition of a and n
b) Subtraction of a and n
c) Multiplication of a and n
d) Division of a and n
7. Which of the following is an invalid assignment operator?
a) a %= 10;
b) a /= 10;
c) a |= 10;
d) None of the mentioned
Sanfoundry Global Education & Learning Series – C Programming Language.
To practice all areas of C language, here is complete set of 1000+ Multiple Choice Questions and Answers.
- Get Free Certificate of Merit in C Programming
- Participate in C Programming Certification Contest
- Become a Top Ranker in C Programming
- Take C Programming Tests
- Chapterwise Practice Tests: Chapter 1, 2, 3, 4, 5, 6, 7, 8, 9, 10
- Chapterwise Mock Tests: Chapter 1, 2, 3, 4, 5, 6, 7, 8, 9, 10
- Practice BCA MCQs
- Apply for Computer Science Internship
- Practice Computer Science MCQs
- Watch Advanced C Programming Videos
- Buy Computer Science Books