Question: What does the following program print and why? Be sure to explain why each line of output prints the way it does to get full

What does the following program print and why? Be sure to explain why each line of output prints the way it does to get full credit.

#include

using namespace std;

int* minimart(int* a, int* b)

{

if (*a < *b) return a; else return b;

}

void swap1(int* a, int *b)

{

int* temp = a; a = b; b = temp;

}

void swap2(int* a, int *b)

{

int temp = *a; *a = *b; *b = temp;

}

int main()

{

int array[6] = { 5, 3, 4, 17, 22, 19 };

int* ptr = minimart(array, &array[2]);

ptr[1] = 9;

ptr += 2;

*ptr = -1;

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!