86. Increment a Counter

In embedded and firmware systems, counters are frequently used to track events such as interrupts, packets, or errors.

You are given a class named DeviceCounter that maintains an internal counter value. The class already contains:

  • A private integer variable count
  • A constructor to initialize the counter
  • A getter function to read the counter value

Your task is to overload the prefix increment operator (++) so that applying ++counter correctly increments the internal counter value by 1.

In main():

  • An integer n is read from input
  • A DeviceCounter object is created with an initial count of 0
  • The prefix ++ operator is applied exactly n times
  • The final counter value is printed

The implementation must use prefix operator overloading, not postfix.

 

Input Specification

  • A single integer n
  • n ≥ 0
  • Represents the number of times the counter should be incremented

Output Specification

  • Print the final counter value in the exact format:

    Final count=<value>
    
  • No extra spaces or newlines

 

Example 1

Input:

3

Output:

Final count=3 

 

Example 2

Input:

5

Output:

Final count=5

 

 

 

 

Loading...

Input

3

Expected Output

Final count=3