43. Increment Value Pointer vs Reference

 Write two functions that increment a number in different ways:

  • void incrementPtr(int* x) → increments the value using a pointer.
  • void incrementRef(int& x) → increments the value using a reference.
     

The program will call both functions and print the results.
 You only need to implement the two functions.


Example
 Input:

5

Output:

After incrementPtr: 6
After incrementRef: 6

 

Input:

0

Output:

After incrementPtr: 1
After incrementRef: 1

 

Loading...

Input

5

Expected Output

After incrementPtr: 6 After incrementRef: 6