answersLogoWhite

0

#include<iostream>

void swap(int* x, int* y)

{

int tmp = *x; *x=*y; *y=tmp;

}

int main()

{

int a=2, b=4;

std::cout<<"a="<<a<<", b="<<b<<std::endl;

swap(&a, &b);

std::cout<<"a="<<a<<", b="<<b<<std::endl;

}

User Avatar

Wiki User

12y ago

What else can I help you with?

Related Questions

What is swap in c plus plus programming language?

It is not a reserved word, so can be an identifier (name of a type/variable/function).


How can write the name in c plus plus language without using cout statement?

I believe, you can use C-function - printf().


Difference between procedure and function in C or C plus plus or Java language?

In C there are functions only, In Java methodsonly (static methods as well), in C++ both.


How do you convert numeric value into alpha value in c plus plus programming language?

use the _itoa function


What is self referential function in c plus plus?

A self-referential function in C++, or in any other supporting language, is a recursive function.


How to swap two numbers by call by reference in c plus plus?

void swap(int&amp; a, int&amp; b ) { a^=b^=a^=b; }


What is the difference between C plus plus and the original language?

C++ is easier to use as you have to learn slightly less and script slightly to make your function(s) work.


What are the building function in c plus plus?

There is no such term as "building function" in C++.


In computer language C plus plus is related to?

C++ is related to C, the language from which it is derived.


What are the interpreter in c plus plus?

C++ is a compiled language, not an interpreted language.


Is c plus plus a complied or interpreted language?

C++ is generally a compiled language.


Bubble sorting in c plus plus?

bubble_sort (int N, int *A) { int i; swap = 1; while (swap) { swap = 0; for (i=0; i&lt;N-1; ++i) { if (A[i] &gt; A[i+1]) { swap = 1; A[i] ^= A[i+1]; A[i+1] ^= A[i]; A[i] ^= A[i+1]; } } } }