003-001-011

Pre and Post Increment Operators

Hard

Problem Description

Pre and Post Increment Operators

In this problem, you will create a program that reads two integers from standard input, uses postfix increment (a++) and prefix increment (++b) in expressions, and displays the evaluation result and final variable values to standard output.

Learning Objective: Understand the difference between prefix (++i) and postfix (i++) increment operators

Overview

Verify how prefix and postfix increment operators are evaluated within expressions.

Input Format

a
b
  • a: Integer for postfix increment
  • b: Integer for prefix increment

Specifications

  • Read integer variables a and b from standard input
  • Use postfix increment (a++) in an expression
  • Use prefix increment (++b) in an expression
  • Output expression result and final variable values

Output Format

Post-increment: value=<valueA>, a=<a after increment>
Pre-increment: value=<valueB>, b=<b after increment>

Sample Input/Output

Input:

3
7

Output:

Post-increment: value=3, a=4
Pre-increment: value=8, b=8

Ready to Try Running Code?

Log in to access the code editor and execute your solutions for this problem.

Don't have an account?

Sign Up