Recall & Review
beginner Click to reveal answer
What does the increment operator (++) do in C?
It increases the value of a variable by 1.
intermediate Click to reveal answer
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.
beginner Click to reveal answer
What does the decrement operator (--) do in C?
It decreases the value of a variable by 1.
intermediate Click to reveal answer
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.
advanced Click to reveal answer
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.
What will be the value of x after this code?
int x = 5;
x++;
int x = 5;
x++;
✗ Incorrect
The x++ increases x by 1, so x becomes 6.
What is the output of this code?
int x = 3;
printf("%d", ++x);
int x = 3;
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.
