Skip to content

Add swap two numbers #2936

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

princesharma2004
Copy link

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

  • Added description of change
  • Added file name matches File name guidelines
  • Added tests and example, test must pass
  • Added documentation so that the program is self-explanatory and educational - Doxygen guidelines
  • Relevant documentation/comments is changed or added
  • PR title follows semantic commit guidelines
  • Search previous suggestions before making a new one, as yours may be a duplicate.
  • 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant