Search
 
SCRIPT & CODE EXAMPLE
 

CPP

C++ set swap

Input  : set1 = {1, 2, 3, 4}
         set2 = {5, 6, 7, 8}
         set1.swap(set2);
Output : set1 = {5, 6, 7, 8}
         set2 = {1, 2, 3, 4}

Input  : set1 = {'a', 'b', 'c', 'd'}
         set2 = {'w', 'x', 'y', 'z'}
         set1.swap(set2);
Output : set1 = {'w', 'x', 'y', 'z'}
         set2 = {'a', 'b', 'c', 'd'}
Comment

c++ swap function

int main()
{
	int a = 5;
	int b = 10;
  
	swap(a, b);
  
	cout << "a = " << a << endl;
	cout << "b = " << b << endl;
}
Comment

C++ Swap Function

    int a, b;

    cout << "Input first number: ";
    cin >> a;
    cout << "Input second number: ";
    cin >> b;

    swap (a, b);

    cout << "After swapping the first number: " << a << endl;
    cout << "After swapping the second number: " << b << endl;
Comment

PREVIOUS NEXT
Code Example
Cpp :: C++ Integer Input/Output 
Cpp :: explicit c++ 
Cpp :: long pi in c++ 
Cpp :: class operator overloading c++ 
Cpp :: how to find even and odd numbers in c++ 
Cpp :: char to int in c++ 
Cpp :: how to have a queue as a parameter in c++ 
Cpp :: kmp algorithm c++ 
Cpp :: c++ data types 
Cpp :: cpp execute command 
Cpp :: stack class implementation to file unix-style in c++ 
Cpp :: How to use jwt in login api in node js 
Cpp :: long long int range c++ 
Cpp :: oncomponentendoverlap ue4 c++ 
Cpp :: resharper fold if statement 
Cpp :: c++ if statement 
Cpp :: char array declaration c++ 
Cpp :: struct node 
Cpp :: nullptr c++ 
Cpp :: Abstract factory C++ code 
Cpp :: statements 
Cpp :: how can I delete a substring from a string in c++? 
Cpp :: compare function in c++ 
Cpp :: options select from array 
Cpp :: 1. Two Sum 
Cpp :: c++ main function parameters 
Cpp :: Write a C++ program using constructor 
Cpp :: print all number between a and b in c++ 
Cpp :: recherche recursive le max dans une liste 
Cpp :: The five most significant revisions of the C++ standard are C++98 (1998), C++03 (2003) and C++11 (2011), C++14 (2014) and C++17 (2017) 
ADD CONTENT
Topic
Content
Source link
Name
4+7 =