The Increment Operator, Postfix and Prefix

Easy

Read an integer n and run two experiments that show the difference between postfix and prefix increment. 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 = 6. Then set x back to n, assign y = ++x, and print after y = ++x: y = 6, x = 6. Each assignment must use the increment operator itself, not + 1. If n cannot be read, print invalid input and return 1. If n is INT_MAX, incrementing it would overflow, so print n is too large to increment 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.

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

How did you find this exercise?

Your rating helps us improve the content.