Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

(5 C++ programming questions): What is output by the following? Assume the necessary header files etc. are included and that the code is in a

(5 C++ programming questions): What is output by the following? Assume the necessary header files etc. are included and that the code is in a main() function.

1. int x=5, y=-1, &rx=x, &ry=y, z;

z = rx + ry; cout << x << ", " << ry << ", " << z;

2. void swap(int &a, int &b) { int hold; hold = a; a = b; b = hold; }

int main() {

int x[5] = {14, 3, 9}; // what is the value of x[3]?

swap(x[0], x[2]);

swap(x[1], x[3]);

for(int i=0; i<4; i++)

cout << x[i] << ", ";

}

3. void dostuff(char a[], char b[]);

int main() {

char s1[] = "PAPOA";

char s2[] = "WEHLO";

dostuff(s1, s2);

cout << s1;

}

void dostuff(char a[], char b[]) {

a[0] = 'Y';

a[2] = b[2];

a[4] = b[4];

}

4. const int ROWS=2, COLS=3;

int a[ROWS][COLS] = { {2, 4, 6}, {7, 5, 3} };

for(int i=0; i

for(int j=0; j

cout << a[i][j] << ", ";

cout << endl;

}

5. const int ROWS=2, COLS=3;

char a[ROWS][COLS] = { {'P', 'A', 'S'}, {'A', 'U', 'N'} };

for(int i=0; i

for(int j=0; j

if( i + j >= 2)

cout << a[i][j];

}

cout << endl;

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

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

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

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

Get Started

Recommended Textbook for

Databases DeMYSTiFieD

Authors: Andy Oppel

2nd Edition

0071747990, 978-0071747998

More Books

Students also viewed these Databases questions

Question

1 What demand is and what affects it.

Answered: 1 week ago