The Decrement Operator, Postfix and Prefix

Easy

Read an integer n and run two experiments that show the difference between postfix and prefix decrement. Print start: x = 5 with the value of n. Then set x to n, assign y = x--, and print after y = x--: y = 5, x = 4. Then set x back to n, assign y = --x, and print after y = --x: y = 4, x = 4. Each assignment must use the decrement operator itself, not - 1. If n cannot be read, print invalid input and return 1. If n is INT_MIN, decrementing it would overflow, so print n is too small to decrement and return 1.

Success Criteria

Your code must pass 5 test case(s) to complete this exercise. 3 hint(s) are available if you need help.

How did you find this exercise?

Your rating helps us improve the content.

Sign in to track your progress

You can work on exercises as a guest, but sign in to track your progress and save your submissions.

This platform is built by its community

Every lesson, project, and tool on HelloC++ is funded by sponsors. Join them and help shape what we build next.

Become a Patron