Question

QUESTION 62 Consider the following code: void Pancake(int x, int& y, int z); void Waffle(int& x,...

QUESTION 62

  1. Consider the following code:

    void Pancake(int x, int& y, int z);
    void Waffle(int& x, int& y);
    int Doughnut(int y, int z);

    int main( )
    {
                int a = 1;
                int b = 2;
                int c = 3;
                int d = 4;

                Pancake(a, b, c);
                Waffle(b, c);
                Pancake(d, c, b);
                d = Doughnut(b, a);
                return 0;
    }

    void Pancake(int x, int& y, int z)
    {
                y += 3;
                z = x + y;
    }

    void Waffle(int& x,int& y)
    {
                int temp;
                temp = x;
                x    = y;
                y    = temp;
    }

    int Doughnut(int y, int z)
    {
                int w;    
    w = y * 2;
                z = w + 3;
                w --;
                return w;
    }

    What are the values of d after the call to function Waffle?

    A.

    8

    B.

    5

    C.

    4

    D.

    3

    E.

    2

    F.

    1

1 points   

QUESTION 63

  1. Consider the following code:

    void Pancake(int x, int& y, int z);
    void Waffle(int& x, int& y);
    int Doughnut(int y, int z);

    int main( )
    {
                int a = 1;
                int b = 2;
                int c = 3;
                int d = 4;

                Pancake(a, b, c);
                Waffle(b, c);
                Pancake(d, c, b);
                d = Doughnut(b, a);
                return 0;
    }

    void Pancake(int x, int& y, int z)
    {
                y += 3;
                z = x + y;
    }

    void Waffle(int& x,int& y)
    {
                int temp;
                temp = x;
                x    = y;
                y    = temp;
    }

    int Doughnut(int y, int z)
    {
                int w;    
    w = y * 2;
                z = w + 3;
                w --;
                return w;
    }

    What are the values of a after the second call to function Pancake?

    A.

    8

    B.

    5

    C.

    4

    D.

    3

    E.

    2

    F.

    1

1 points   

QUESTION 64

  1. Consider the following code:

    void Pancake(int x, int& y, int z);
    void Waffle(int& x, int& y);
    int Doughnut(int y, int z);

    int main( )
    {
                int a = 1;
                int b = 2;
                int c = 3;
                int d = 4;

                Pancake(a, b, c);
                Waffle(b, c);
                Pancake(d, c, b);
                d = Doughnut(b, a);
                return 0;
    }

    void Pancake(int x, int& y, int z)
    {
                y += 3;
                z = x + y;
    }

    void Waffle(int& x,int& y)
    {
                int temp;
                temp = x;
                x    = y;
                y    = temp;
    }

    int Doughnut(int y, int z)
    {
                int w;    
    w = y * 2;
                z = w + 3;
                w --;
                return w;
    }

    What are the values of b after the second call to function Pancake?

    A.

    8

    B.

    5

    C.

    4

    D.

    3

    E.

    2

    F.

    1

1 points   

QUESTION 65

  1. Consider the following code:

    void Pancake(int x, int& y, int z);
    void Waffle(int& x, int& y);
    int Doughnut(int y, int z);

    int main( )
    {
                int a = 1;
                int b = 2;
                int c = 3;
                int d = 4;

                Pancake(a, b, c);
                Waffle(b, c);
                Pancake(d, c, b);
                d = Doughnut(b, a);
                return 0;
    }

    void Pancake(int x, int& y, int z)
    {
                y += 3;
                z = x + y;
    }

    void Waffle(int& x,int& y)
    {
                int temp;
                temp = x;
                x    = y;
                y    = temp;
    }

    int Doughnut(int y, int z)
    {
                int w;    
    w = y * 2;
                z = w + 3;
                w --;
                return w;
    }

    What are the values of c after the second call to function Pancake?

    A.

    8

    B.

    5

    C.

    4

    D.

    3

    E.

    2

    F.

    1

0 0
Add a comment Improve this question Transcribed image text
Answer #1

#include<iostream>
using namespace std;

void Pancake(int x, int& y, int z);
void Waffle(int& x, int& y);
int Doughnut(int y, int z);

int main( )
{
int a = 1;
int b = 2;
int c = 3;
int d = 4;

Pancake(a, b, c);//a = 1 ,b = 2+3 = 5 ,c = 3
Waffle(b, c); //value of b and c swapped b = 3 ,c=5
Pancake(d, c, b); //d=4 , c = c+3 = 5+3 =8 , b = 3
d = Doughnut(b, a); //d=5
return 0;
}

void Pancake(int x, int& y, int z)
{
y += 3;
z = x + y;
}

void Waffle(int& x,int& y)
{
int temp;
temp = x;
x = y;
y = temp;
}

int Doughnut(int y, int z)
{
int w;
w = y * 2; //w = 3*2 = 6
z = w + 3; //z = 6+3 = 9
w --; //w = 6-1 = 5
return w; //return 5
}
(62)The values of d after the call to function Waffle = 4
(63)The values of a after the second call to function Pancake = 1
(64)The values of b after the second call to function Pancake = 3
(65)The values of c after the second call to function Pancake = 8

Add a comment
Know the answer?
Add Answer to:
QUESTION 62 Consider the following code: void Pancake(int x, int& y, int z); void Waffle(int& x,...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • What is the output of the following program? int main(void) { int x, y, z; x...

    What is the output of the following program? int main(void) { int x, y, z; x = 5; y= test(x); z= x + y; cout<< setw(4)<<x <<” + “<<setw(4)<<y<<”=” << setw(4)<<z<<endl; return 0; } int test (int x) { int w; w = x + 10; return (w); }

  • Consider the following program: # include <iostream> int x = 3, y = 5; void foo(void)...

    Consider the following program: # include <iostream> int x = 3, y = 5; void foo(void) { x = x + 2; y = y + 4; } void bar(void) { int x = 10; y = y + 3; foo( ); cout << x << endl; cout << y << endl; } void baz(void) { int y = 7; bar( ); cout << y << endl; } void main( ) { baz( ); } What output does this program...

  • XCORE Question 1 Consider the following program void Elint x, int y Y = y +...

    XCORE Question 1 Consider the following program void Elint x, int y Y = y + 1 cout<<x<<"*«y << endl; void nain) 1 int i, a13): all) = 15; a 2) - 203 a13) = 25; cout <i«"" <all) <<"" << a12) << ""« a[3] << endl; cout <i<** <all) << "" << a12) <<""« a[3] << endl; What values of the variable and array A are printed with the following rules. a parameters are passed by value bi parameters...

  • Consider the following program: # include <iostream> using namesapce std; void Func(int a, int bl double...

    Consider the following program: # include <iostream> using namesapce std; void Func(int a, int bl double number-25.0: int main) f int x-18, y-20; cout<c"Before: x- kex<" and y-eyecendl; Fundxy 1// end of main void Funcfint a, int b) int sum a+b; a-200; b-300; numberanumber+1.0 Which of the statements below are correct? (Select only the correct answers. There may be more than one) D A The statement double number-25.0; declares a global variable number B. The variables x and y are...

  • (a) Consider the following C++ function: 1 int g(int n) { 2 if (n == 0)...

    (a) Consider the following C++ function: 1 int g(int n) { 2 if (n == 0) return 0; 3 return (n-1 + g(n-1)); 4} (b) Consider the following C++ function: 1 bool Function (const vector <int >& a) { 2 for (int i = 0; i < a. size ()-1; i ++) { 3 for (int j = i +1; j < a. size (); j ++) { 4 if (a[i] == a[j]) return false; 5 6 } 7 return...

  • Three variables x, y, and z defined as unsigned char, short, and int types in C...

    Three variables x, y, and z defined as unsigned char, short, and int types in C Programming. What are the maximum values they can take? Compare the following C programs. After execution of this short programs what will be the value of x if printed in function? void foo(void); int main(void){             foo();             foo();             foo(); return 0; } void foo() {             int x = 1;             x++;               } void foo(void); int main(void){             foo();             foo();...

  • C++ 4. What is a driver program? 43. Consider the following function and code segment. void...

    C++ 4. What is a driver program? 43. Consider the following function and code segment. void Onet int first, int& second first 17 secondfirst 1 int main) // other code int j4; int k3; One(j, k) // other code .. After the call to OneGi, k); what are the values ofj and k?

  • Consider the following code C++ like program: int i, j, arr[5]; //arr is an array starting...

    Consider the following code C++ like program: int i, j, arr[5]; //arr is an array starting at index 0 void exchange(int x, int y) { int temp:= x; x:= y; y:= temp; } main(){ for (j = 0; j < 5; j++) arr[j]:= j; i:= 1; exchange(i, arr[i+1]); output(i, arr[2]); //print i and arr[2] } What is the output of the code if both parameters in function swapping are passed by: a- value? b- reference? c- value-result?

  • C++ 1. A?B?C?D? which one is correct 2. 3A, 3B #include<iostream> using namespace std; void swap0(int*...

    C++ 1. A?B?C?D? which one is correct 2. 3A, 3B #include<iostream> using namespace std; void swap0(int* ptri, int* ptr2) { int *temp; temp = ptr1; ptr1 = ptr2; ptr2 = temp; void swap1(int ptri, int ptr2){ int temp; temp = ptri; ptr1 = ptr2; ptr2 = temp; portion void swap2(int *&ptri, int *&ptr2){ int* temp; temp = ptr1; ptr1 = ptr2; ptr2 = temp; void swap3(int &ptri, int &ptr2) { int temp; temp = ptr1; ptr1 = ptr2; ptr2 =...

  • 20) What is the output of the following segment of C code: int avg(int n, int*...

    20) What is the output of the following segment of C code: int avg(int n, int* a); int main () {             int array[4]={1,0,6,9};             printf("%d", avg(4, array)+ 1);             system("pause");             return 0; } int avg(int n, int* a) { int i, sum=0; for (i=0;i<n;i++) { sum+=a[i]; } return sum/n; } a) 16 b) 5 c) 4 d) 8 21) What is the output of the following segment of C code: int x = 2; int y = 3;...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT