C++

Swap Two Numbers in C++1 min read

Write a C++ program to swap two numbers. The first program uses temporary variable to swap numbers, whereas the second program doesn’t use temporary variables.

 

Example 1: Swap Numbers (Using Temporary Variable)

C++ Code:

 

Example 2: Swap Numbers Without Using Temporary Variables

C++ Code:




Output:

Leave a Comment