Commit 7990091
committed
feat: Add FunctionsCC class with calculateSum method
WHAT the code does:
- Defines a `FunctionsCC` class with a static method `calculateSum(int num1, int num2)`.
- `calculateSum()` computes the sum of two integers and prints the result.
- `main()` demonstrates by calling `calculateSum(3, 4)` → prints `7`.
WHY this matters:
- Demonstrates creating and invoking a **user-defined method** with parameters.
- Reinforces how arguments are passed into methods.
- Introduces basic function abstraction for code reuse.
HOW it works:
1. `calculateSum(3, 4)` → adds numbers to get `7`.
2. Prints the result directly from inside the method.
Tips & gotchas:
- Prints the sum but doesn’t return it → less flexible for reuse in other calculations.
- Could be modified to `return int` instead of `void` for broader utility.
- Works only for two integers; overloading or varargs could allow more flexibility.
- Use descriptive messages in output for clarity.
Use-cases:
- Educational demo for **methods with parameters**.
- Simple utility for arithmetic practice.
- Starter point for building calculator-like applications.
- Helps beginners separate logic into reusable methods.
Short key: class-functions cc-calculate sum.
Signed-off-by: https://github.com/Someshdiwan <[email protected]>1 parent 4a09e17 commit 7990091
1 file changed
+3
-6
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
2 | | - | |
3 | | - | |
4 | | - | |
| 1 | + | |
| 2 | + | |
5 | 3 | | |
6 | 4 | | |
7 | 5 | | |
8 | | - | |
9 | | - | |
| 6 | + | |
10 | 7 | | |
11 | 8 | | |
12 | 9 | | |
0 commit comments