C-Plus-Plus
C-Plus-Plus copied to clipboard
Add swap two numbers
Description of Change
Added a program to swap two numbers using reference variables in C++.
The program includes:
- A function
swap_two_numbers(int &a, int &b)to swap two integers. - Two test functions (
test1()andtest2()) to verify the correctness of the swap function. - Assert statements for automatic validation.
- Doxygen-style comments for documentation and better understanding.
- A
main()function that runs the tests and printsSuccess.on passing all assertions.
Checklist
- [x] Added description of change
- [x] Added file name matches File name guidelines
- [x] Added tests and example, test must pass
- [x] Added documentation so that the program is self-explanatory and educational - Doxygen guidelines
- [x] Relevant documentation/comments is changed or added
- [x] PR title follows semantic commit guidelines
- [x] Search previous suggestions before making a new one, as yours may be a duplicate.
- [x] I acknowledge that all my contributions will be made under the project's license.
Notes:
Added a fully tested and documented implementation of swapping two numbers using a temporary variable. Code is designed to be self-explanatory and follows Doxygen documentation style.