reference function in c++
C++
// function definition to swap the values.
void swap(int &x, int &y) {
int temp;
temp = x; /* save the value at address x */
x = y; /* put y into x */
y = temp; /* put x into y */
return;
}#include <iostream>
using namespace std;
// function declaration
void swap(int &x, int &y);
int main () {
// local variable declaration:
int a = 100;
int b = 200;
cout << "Before swap, value of a :" << a << endl;
cout << "Before swap, value of b :" << b << endl;
/* calling a function to swap the values using variable reference.*/
swap(a, b);
cout << "After swap, value of a :" << a << endl;
cout << "After swap, value of b :" << b << endl;
return 0;
}
Also in C++:
- Title
- lopping over an array c++
- Category
- C++
- Title
- hobo 8
- Category
- C++
- Title
- binary search in set c++
- Category
- C++
- Title
- variant hold type
- Category
- C++
- Title
- FInd the element which appears more than n/2 times C++
- Category
- C++
- Title
- how to create object in c++
- Category
- C++
- Title
- c++ isalphanum
- Category
- C++
- Title
- C++ string format ctime
- Category
- C++
- Title
- placement new c++
- Category
- C++
- Title
- c++ read matttrix from text file
- Category
- C++
- Title
- leveling system c++
- Category
- C++
- Title
- Convert binary tree to a doubly linked list
- Category
- C++
- Title
- c++ give options
- Category
- C++
- Title
- c++ parse int
- Category
- C++
- Title
- min and max heap in cpp
- Category
- C++
- Title
- c++ empty stream
- Category
- C++
- Title
- inserting an element in an set c++
- Category
- C++
- Title
- mysqli connect
- Category
- C++
- Title
- namespace file linking c++
- Category
- C++
- Title
- how to initialize a vector in c++
- Category
- C++
- Title
- c++ menu selection with arrow keys
- Category
- C++
- Title
- c++ program for addition of two numbers using functions
- Category
- C++
- Title
- how to find the mode of a vector c++
- Category
- C++
- Title
- c++ find prime numbers
- Category
- C++
- Title
- self in c++
- Category
- C++
- Title
- get data from terminal c++
- Category
- C++
- Title
- c++ try
- Category
- C++
- Title
- correct sequence of compilation process in c++
- Category
- C++
- Title
- initialize array c++
- Category
- C++
- Title
- add a timer c++
- Category
- C++
- Title
- caesar cipher program in c++
- Category
- C++
- Title
- bitset c++
- Category
- C++
- Title
- insertion sort in c++ program
- Category
- C++
- Title
- c++ string to int
- Category
- C++
- Title
- nearest integer rounding in c++
- Category
- C++
- Title
- cout console
- Category
- C++
- Title
- c++ formatting
- Category
- C++
- Title
- how to get input from the console in c++
- Category
- C++
- Title
- monotonic deque
- Category
- C++
- Title
- c++ multiple inheritance diamond problem
- Category
- C++
- Title
- never gonna give you up lyrics
- Category
- C++
- Title
- compare function in sort c++ stl
- Category
- C++
- Title
- what are the different ways to traverse a binary tree
- Category
- C++
- Title
- set mimetype validation in mongoose
- Category
- C++
- Title
- ceil in c++
- Category
- C++
- Title
- linear search in c++
- Category
- C++
- Title
- passing array to function c++ pointer
- Category
- C++
- Title
- initialize int c++
- Category
- C++
- Title
- set lower bound c++
- Category
- C++
- Title
- modular exponentiation c++
- Category
- C++
- Title
- else if c++
- Category
- C++
- Title
- Create a program that finds the minimum value in these numbers
- Category
- C++
- Title
- std::iomanip c++
- Category
- C++
- Title
- strchr function in c++
- Category
- C++
- Title
- how to declare a vector in c++
- Category
- C++
- Title
- How to find the kth smallest number in cinstant space
- Category
- C++
- Title
- Read multiple files(.txt) c++
- Category
- C++
- Title
- popualte an array c++
- Category
- C++
- Title
- clear qlayout
- Category
- C++
- Title
- convert entire string to lowercase c++
- Category
- C++
- Title
- qt make widget ignore mouse events
- Category
- C++
- Title
- int max in c++
- Category
- C++
- Title
- Temporary file using MSFT API in cpp
- Category
- C++
- Title
- ue4 c++ struct
- Category
- C++
- Title
- c++ method name
- Category
- C++
- Title
- while loops
- Category
- C++
- Title
- exponenciacion binaria
- Category
- C++
- Title
- pop from between string c++
- Category
- C++
- Title
- rick astley - never gonna give you up
- Category
- C++
- Title
- c++ compiler for sublime text
- Category
- C++
- Title
- how to measure program run time in c++
- Category
- C++
- Title
- convert string to stream c++
- Category
- C++
- Title
- convert decimal to binary in c++
- Category
- C++
- Title
- is TLE means my code is correct but taking more time to computr
- Category
- C++
- Title
- array<string, 7> c++
- Category
- C++
- Title
- how to get the prime number in c++ where time complexity is 0(log n)
- Category
- C++
- Title
- when ratings will be updated for codechef
- Category
- C++
- Title
- shortest path with bfs in c++
- Category
- C++
- Title
- sort function in vector c++ stl
- Category
- C++
- Title
- cpp pi from acos
- Category
- C++
- Title
- c++ class method example
- Category
- C++
- Title
- min heap declaration in c++ stl
- Category
- C++
- Title
- how to have a queue as a parameter in c++
- Category
- C++
- Title
- ue4 c++ array
- Category
- C++
- Title
- widechartomultibyte
- Category
- C++
- Title
- fast input output in c++
- Category
- C++
- Title
- unordered_map c++
- Category
- C++
- Title
- count a character in a string c++
- Category
- C++
- Title
- c++ yes no question
- Category
- C++
- Title
- hashing in competitive programming
- Category
- C++
- Title
- new keyword in cpp
- Category
- C++
- Title
- c++ write new file
- Category
- C++
- Title
- cin.ignore
- Category
- C++
- Title
- c++ constructor
- Category
- C++
- Title
- function declerations in C++
- Category
- C++
- Title
- how to print to the serial monitor arduino
- Category
- C++
- Title
- how to convert a string to a double c++
- Category
- C++
- Title
- how to compare lower case character to uppercase cpp
- Category
- C++
- Title
- arduino delay millis
- Category
- C++
- Title
- two sum problem in c++
- Category
- C++