Answered You can hire a professional tutor to get the answer.

QUESTION

1 a) Write the output of the following program.

1 a) Write the output of the following program. (15 pts )#include <iostream>using namespace std;void fun1 (int *p, int *&q) {*p = 100;p = p + 2;*p = *q;*q = *(p+1);cout << "p=" << *p << " q=" << *q << "n";}bool fun2 (int x[], int size) {int *p = x;int *q;q = p;for (int i=1; i<size; i++) {x[i] += x[i-1];cout << x[i] << " ";}cout << "n";fun1 (p, q);return (*p == *q);}int main ( ) {int a[5] = {2,4,6,8,10};if (fun2 (a,5))cout << "truen";elsecout << "falsen";for (int i=0; i<5; i++)cout << a[i] << " ";return 0;}1 b) Write the output of the following program. (15 pts)#include <iostream>using namespace std;int fun ( int*& p, int* q) {*p = 12;p = p+3;q = p-1;*q = *(p+1) + *q;*p += 2;cout << "p=" << *p << " q=" << *q << "n";return (*q)%(*p);}int main( ) {int y[5] = {1,2,3,4,5};int* p = y;int *q = new int;*q = fun ( p, q );for (int i=0; i<5; i++)cout << y[i] << " ";cout << "np=" << *p << " q=" << *q;return 0;}

Show more
LEARN MORE EFFECTIVELY AND GET BETTER GRADES!
Ask a Question