Recall & Review
beginner
What does the increment operator (++) do in C?
It increases the value of a variable by 1.
Click to reveal answer
intermediate
What is the difference between prefix (++x) and postfix (x++) increment?
Prefix increments the value before using it, postfix uses the value first then increments it.
Click to reveal answer
beginner
What does the decrement operator (--) do in C?
It decreases the value of a variable by 1.
Click to reveal answer
intermediate
How does the postfix decrement (x--) behave in an expression?
It uses the current value of x in the expression, then decreases x by 1.
Click to reveal answer
advanced
Can increment and decrement operators be used with non-integer types in C?
Yes, they can be used with types like char and pointers, increasing or decreasing their value accordingly.
Click to reveal answer
What will be the value of x after this code? <br> int x = 5; <br> x++;
✗ Incorrect
The x++ increases x by 1, so x becomes 6.
What is the output of this code? <br> int x = 3; <br> printf("%d", ++x);
✗ Incorrect
++x increments x first, so x becomes 4, then prints 4.
Which operator decreases a variable's value by 1?
✗ Incorrect
-- is the decrement operator that subtracts 1 from the variable.
What is the difference between x++ and ++x in expressions?
✗ Incorrect
x++ uses the value first then increments; ++x increments first then uses the value.
Can you use increment operators on pointers in C?
✗ Incorrect
Incrementing a pointer moves it to the next element in memory according to its type size.
Explain how prefix and postfix increment operators work differently in C.
Think about when the variable's value changes relative to its use.
You got /3 concepts.
Describe how decrement operators can be used with pointers and what effect they have.
Consider how memory addresses change when you decrement a pointer.
You got /3 concepts.