C-Plus-Plus icon indicating copy to clipboard operation
C-Plus-Plus copied to clipboard

Add swap two numbers

Open princesharma2004 opened this issue 5 months ago • 1 comments

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() and test2()) 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 prints Success. 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.

princesharma2004 avatar Apr 28 '25 17:04 princesharma2004