Search
 
SCRIPT & CODE EXAMPLE
 

CPP

c++ swapping two numbers

#include <iostream>
using namespace std;

int main()
{
    int a,b,temp;
    cout <<"Enter two values that you wants to swap:";
    cin >> a >> b;

    cout << "Before swapping." << endl;
    cout << "a = " << a << ", b = " << b << endl;

    temp = a;
    a = b;
    b = temp;

    cout << "
After swapping." << endl;
    cout << "a = " << a << ", b = " << b << endl;

    return 0;
}
Comment

PREVIOUS NEXT
Code Example
Cpp :: Appending a vector to a vector in C++ 
Cpp :: factorial using recursion cpp 
Cpp :: qt disable resizing window 
Cpp :: how to clear console c++ 
Cpp :: how to split a string into words c++ 
Cpp :: c++ compare time 
Cpp :: roscpp publish int32 
Cpp :: c++ open all files in directory 
Cpp :: c++ check if char is number 
Cpp :: Frequency of a substring in a string C++ 
Cpp :: map in c++ sorted descending order 
Cpp :: C++ Find the sum of first n Natural Numbers 
Cpp :: prime numbers less than a given number c++ 
Cpp :: how print fload wiht 3 decimal in c++ 
Cpp :: flags for g++ compiler 
Cpp :: c++ fizzbuzz 
Cpp :: c++ arithmetic operators 
Cpp :: string iterator in c++ 
Cpp :: c++ greatest common divisor 
Cpp :: round double to 2 decimal places c++ 
Cpp :: index string c++ 
Cpp :: functors in c++ 
Cpp :: set clear c++ 
Cpp :: cpp pushfront vector 
Cpp :: rotate array cpp 
Cpp :: c++ rand include 
Cpp :: ascii conversion cpp 
Cpp :: unique_ptr syntax 
Cpp :: argument vs parameter coding c++ 
Cpp :: c #define 
ADD CONTENT
Topic
Content
Source link
Name
2+7 =