answersLogoWhite

0


Best Answer

#include<iostream>

using namespace std;

void swap(int &i, int &j)

{

int temp = i;

i = j;

j = temp;

}

int main()

{

int i,j;

cin>>i>>j;

cout << i << j << endl;

swap(i,j);

cout << i << j;

return 0;

}

User Avatar

Wiki User

14y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: Write a function using reference variables as arguments to swap the values of a pair of integers?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Continue Learning about Engineering

How are char -type constants and char-type variables interpreted when used as operands with a relational operator?

As integers, within range -128..127 if signed, 0..255 if unsigned.


Write a recursive function CountOddNumbers that accepts as parameters an array of integers and the array size The function should count and return the odd numbers in the array of integer?

You mean an iterative function, not a recursive one. A recursive function is one that calls itself with altered arguments, typically used to implement divide-and-conquer algorithms. Since the arguments remain the same and you're not dividing the array into smaller subsets, recursion is not necessary. An iterative loop is all you need: typedef unsigned int UINT; const UINT CountOddNumbers( const UINT* const A, const UINT size) { UINT result=0; for(UINT i=0; i&lt;size; ++i) result += A[i]&amp;1; return(result); } Note that this function is not safe, since size is not guaranteed to reflect the actual size of A. In C++, it's better to use a vector object, since vectors encapsulate the actual size of the embedded array: const UINT CountOddNumbers( const std::vector&lt;UINT&gt; A) { UINT result=0; for(UINT i=0; i&lt;A.size(); ++i) result += A[i]&amp;1; return(result); }


Rules for function overloading?

It's a way by which you use define the same function for different input types. For example, think about the the operator "+" which in java works for adding integers, floating point numbers and even string concatenation. The way such functionality is achieved is by overloading.


How do you use pow function in c?

Either you can use the pre defined function "pow" in the &lt;math.h&gt; header file OR you can make a user defined function to do the same operation. 1.Using the pre defined function in &lt;math.h&gt; : The function is a of datatype double and accepts only values in double. So, prototype declaration is: double pow(double x,double y); Pass the values to the function and it'll return the value of xy. In the calling function it can be declared as: double power=pow(x,y); 2.USER DEFINED FUNCTION: double power(double x,int y); int main() { double x,result; int y; cout&lt;&lt;"\nEnter the base: "&lt;&lt;; cin&gt;&gt;x; cout&lt;&lt;"\nEnter the exponential power: "; cin&gt;&gt;y; result=power(x,y); cout&lt;&lt;"The result of x to the power y is: "&lt;&lt;result; return 0; } double power(double x,int y) { for(int i=0;i&lt;=y;i++) { x*=x; } return x; }


Write an algorithm for addition of two integer?

1.Declare three variables asint a,b,c;2.Get the Input of two numbers of Integers from the user:scanf("%d",&a);scanf("%d",&b);3.add a and b and store the result in c4. print c

Related questions

What are integres?

The integral zeros of a function are integers for which the value of the function is zero, or where the graph of the function crosses the horizontal axis.


Is there ever a point on the equation 2y3x where both variables are integers?

Sorry, I meant 2^y=3x


When subtracting integers with variables that have different exponents do you subtract the exponents too?

You do not. The exponent is only subtracted in division.


What are integral zeros?

The integral zeros of a function are integers for which the value of the function is zero, or where the graph of the function crosses the horizontal axis.


What is an arithmetic function?

An arithmetic function is any function which is defined for all positive integers, and has values which are either real or complex.


Is the cardinality of an infinitely countable set the same as the rational numbers?

Yes. There is an injective function from rational numbers to positive rational numbers*. Every positive rational number can be written in lowest terms as a/b, so there is an injective function from positive rationals to pairs of positive integers. The function f(a,b) = a^2 + 2ab + b^2 + a + 3b maps maps every pair of positive integers (a,b) to a unique integer. So there is an injective function from rationals to integers. Since every integer is rational, the identity function is an injective function from integers to rationals. Then By the Cantor-Schroder-Bernstein theorem, there is a bijective function from rationals to integers, so the rationals are countably infinite. *This is left as an exercise for the reader.


What are numbers in a subtraction problem called?

regardless of what the problem is, they are always called integers. unless you have variables or fractions in the problem.


Why isn't 2 or any other even positive integer a trivial zero of the Riemann Zeta Function?

Coz the gamma function is singular for all negative integers. The factorial for negative integers is not defined.


Are p and q integers?

Those letters are indeed often used to represent integers. But in practice, it's best to always check what assumptions are made. If certain variables (letters) are meant to be integers only, for example for some theorem, this should be stated explicitly.


What is the function whose domain is a set of consecutive integers there are finite and infinite?

sequence


How can you check if a variable is a string or an integer in PHP?

Integers - The "is_int()" function can be used to check if a variable is has an integer for its value. ---- is_int($variable); // Returns true if $variable is an integer - otherwise false ---- Numeric Strings - Numeric strings are strings with numbers (or things that count as numbers) in them. Numeric-string variables are not integer variables. Numeric-string variables are passed on through forms, instead of integer variables - if you were wondering. Check form values using string formats, and not integer formats. The "is_numeric()" function can be used to check if a variable is a string with numbers - and only numbers - in it (except things that add up to be numbers). ---- is_numeric($variable); // Returns true if $variable is a string, and only contains numbers (broadly speaking) - false otherwise ---- Strings - String values are just text, basically. String variables can contain integers, but that does not make it an integer-type variable - it makes it a numeric string variable. The "is_string" function can be used to check if a variable contains the value of a string. ---- is_string($variable); // Returns true if $variable is a string - false otherwise


What are the important features of swift programming?

1 )It eliminates entire classes of unsafe code2)Variables are always initialized before use 3)Arrays and integers are checked for overflow4)Memory is managed automatically5)Instead of using "if" statement in conditional programming, swift has "switch" function