Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access with AI-Powered Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions