QUESTION 62
|
Consider the following code: void Pancake(int x, int& y, int z); int main( )
Pancake(a, b, c); void Pancake(int x, int& y, int z) int Doughnut(int y, int z) |
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
|
Consider the following code: void Pancake(int x, int& y, int z); int main( )
Pancake(a, b, c); void Pancake(int x, int& y, int z) int Doughnut(int y, int z) |
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
|
Consider the following code: void Pancake(int x, int& y, int z); int main( )
Pancake(a, b, c); void Pancake(int x, int& y, int z) int Doughnut(int y, int z) |
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
|
Consider the following code: void Pancake(int x, int& y, int z); int main( )
Pancake(a, b, c); void Pancake(int x, int& y, int z) int Doughnut(int y, int z) |
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 |
#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
QUESTION 62 Consider the following code: void Pancake(int x, int& y, int z); void Waffle(int& x,...
C++ QUESTION 13 Still using the same code, what are the values of x AFTER the call to function Squirrel? void Chipmunk(int a, int b, int& c); void Squirrel(int& a, int& b); int Feature(int b, int c); int main( ) { int w = 1; int x = 2; int y = 3; int z = 4; Chipmunk(w, x, y); Squirrel(x, y); Chipmunk(z, y, x); z = Feature(x, w); return 0;...
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) { 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 + 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...
(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...
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...
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 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 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?
QUESTION 6 What is the output of following C code? struct numbers { int x = 2; int y = 3; } int main() { struct numbers nums; nums.x = 110; nums.y = 100; printf("%d\n%d", nums.x, nums.y); return 0; } A. Compile-time Error B. 110 100 C. 2 3 D. Run-time Error 2 points QUESTION 7 What is the output of following C code? typedef struct student { char *stud; }s1; int main() { s1 s; s.stud...