Given below are three implementations of the swap function: a. void swap (int a, int b) {
Fantastic news! We've Found the answer you've been seeking!
Question:
Given below are three implementations of the swap function:
a. void swap (int a, int b)
{
int temp;
temp = a;
a = b;
b = temp;
}
int main ()
{
int i = 0,
j = 1;
swap (i, j);
}
b. void swap (int &a, int &b)
{
int temp;
temp = a;
a = b;
b = temp;
}
int main ( )
{
int i = 0,
j = 1;
swap (i, j);
}
- void swap (int *a, int *b)
{
int *temp;
temp = a;
a = b;
b = temp;
}
int main ( )
{
int i = 0,
j = 1;
swap (&i, &j);
}
Which of these would actually swap the contents of the two integers i and j ?
A. a only
B. b only
C. c only
D. a and b only 6.
E. b and c only
Related Book For
Posted Date: