answersLogoWhite

0

#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

15y ago

What else can I help you with?

Continue Learning about Engineering

Variable Is a location in the computer's memory where a value can be stored for use by a?

program. Each variable has a name that serves as an identifier, allowing the program to reference and manipulate the stored value. Variables can hold different types of data, such as integers, strings, or booleans, and their values can be changed throughout the program's execution. This flexibility makes variables essential for managing data and controlling the program's behavior.


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; }

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.


Variable Is a location in the computer's memory where a value can be stored for use by a?

program. Each variable has a name that serves as an identifier, allowing the program to reference and manipulate the stored value. Variables can hold different types of data, such as integers, strings, or booleans, and their values can be changed throughout the program's execution. This flexibility makes variables essential for managing data and controlling the program's behavior.


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.


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 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.


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.


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


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