explain your code for following questions: - A function that performs bubble sort on an int array - A function that uses call-by-reference to switch two values - A function that uses call-by-value to...

1 answer below »
explain your code for following questions: - A function that performs bubble sort on an int array - A function that uses call-by-reference to switch two values - A function that uses call-by-value to pretend switching two values (which actually does not) please explain every line of the code
Answered Same DayAug 25, 2021

Answer To: explain your code for following questions: - A function that performs bubble sort on an int array -...

Kunal answered on Aug 27 2021
148 Votes
#include
using namespace std;
// this functions gets values as parameters
void swapWit
hValues(int a, int b) {
int temp = a;
a= b;
b = temp;
}
//this functions gets references of the values
void swapWithReference(int *a, int *b) {
int temp = *a;
*a = *b;
*b = temp;
}
int main()
{
int array[] = {10,9,8,7,6,5,4,3,2,1}; // initializing array
int len = sizeof(array)/sizeof(array[0]); // length of an array
int i,j,temp; // loop variable and temporary variables
...
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here