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;
}
void Chipmunk(int a, int b, int& c)
{
a += 2;
c = a + b;
}
void Squirrel(int& a, int& b)
{
int temp;
temp = a;
a = b;
b = temp;
}
int Feature(int b, int c)
{
b = c;
c = b;
return c;
}
1 points
QUESTION 14
Still using the same code, what is the value of y 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;
}
void Chipmunk(int a, int b, int& c)
{
a += 2;
c = a + b;
}
void Squirrel(int& a, int& b)
{
int temp;
temp = a;
a = b;
b = temp;
}
int Feature(int b, int c)
{
b = c;
c = b;
return c;
}
QUESTION 15
Still using the same code, what is the values of z 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;
}
void Chipmunk(int a, int b, int& c)
{
a += 2;
c = a + b;
}
void Squirrel(int& a, int& b)
{
int temp;
temp = a;
a = b;
b = temp;
}
int Feature(int b, int c)
{
b = c;
c = b;
return c;
}
QUESTION 16
Still using the same code, what is the value of w AFTER the second call to function Chipmunk?
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;
}
void Chipmunk(int a, int b, int& c)
{
a += 2;
c = a + b;
}
void Squirrel(int& a, int& b)
{
int temp;
temp = a;
a = b;
b = temp;
}
int Feature(int b, int c)
{
b = c;
c = b;
return c;
}
QUESTION 17
Still using the same code, what is the value of x AFTER the second call to function Chipmunk?
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;
}
void Chipmunk(int a, int b, int& c)
{
a += 2;
c = a + b;
}
void Squirrel(int& a, int& b)
{
int temp;
temp = a;
a = b;
b = temp;
}
int Feature(int b, int c)
{
b = c;
c = b;
return c;
}
QUESTION 18
Still using the same code, what is the value of y AFTER the second call to function Chipmunk?
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;
}
void Chipmunk(int a, int b, int& c)
{
a += 2;
c = a + b;
}
void Squirrel(int& a, int& b)
{
int temp;
temp = a;
a = b;
b = temp;
}
int Feature(int b, int c)
{
b = c;
c = b;
return c;
}
QUESTION 19
Still using the same code, what is the value of z AFTER the second call to function Chipmunk?
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;
}
void Chipmunk(int a, int b, int& c)
{
a += 2;
c = a + b;
}
void Squirrel(int& a, int& b)
{
int temp;
temp = a;
a = b;
b = temp;
}
int Feature(int b, int c)
{
b = c;
c = b;
return c;
}
QUESTION 20
Still using the same code, what is the value of w AFTER the call to function Feature?
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;
}
void Chipmunk(int a, int b, int& c)
{
a += 2;
c = a + b;
}
void Squirrel(int& a, int& b)
{
int temp;
temp = a;
a = b;
b = temp;
}
int Feature(int b, int c)
{
b = c;
c = b;
return c;
}
QUESTION 21
Still using the same code, what is the value of x AFTER the call to function Feature?
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;
}
void Chipmunk(int a, int b, int& c)
{
a += 2;
c = a + b;
}
void Squirrel(int& a, int& b)
{
int temp;
temp = a;
a = b;
b = temp;
}
int Feature(int b, int c)
{
b = c;
c = b;
return c;
}
A. 1 B. 2 C. 4 D. 6 E. 8
ANSWER:-
QUESTION (13):-
OPTION(E) 5
QUESTION (14):-
OPTION (B) 2
QUESTION (15):-
OPTION (D) 4
QUESTION (16):-
OPTION (A) 1
QUESTION (17):-
OPTION (E) 8
QUESTION (18):-
OPTION (B) 2
QUESTION (19):-
OPTION (C) 4
QUESTION (20):-
OPTION (A) 1
QUESTION (21):-
OPTION (E) 8
C++ QUESTION 13 Still using the same code, what are the values of x AFTER the...
QUESTION 62 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; ...
Study the c++ code below and answer the question on templates after // A polymorphic swap function for any type of object (an example) template<typename T> void MySwap( T& x, T& y) { T temp; temp = x; x = y; y = temp; } // A polymorphic class holding an [x,y] position of any type template<class T> class Position { public: Position(T x=0, T y=0) : x_(x), y_(y) {} friend std::ostream& operator<<(std::ostream& os, const Position& p) { return os...
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...
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 =...
Question 3 Run the following code and explain, using your own words, what is happening with each variable (w,x,y,z) and what is the difference between ++x and w++ (is there any influence on the result between prefix or postfix ++ operator?). Provide a snippet of the output showing the result. int main() { int w = 20, x = 20; int y = 5, z = 5; y = y + (++x); z = z + (w++); cout << "x="...
code in C++
Name: Homework #13 What are the two memory pools for programs running a modern operating system? 1. Given the following program: 2. sincludeciostream> using nanespace std; void func1(int); int main() int a 5, b 10; func1(a): return 0; void func1(int a) int z(2]: int ys a. What is on the stack before the first function call (assume a memory starting address of ex1018)? b. What is on the stack after the function call is executed (before returning...
What is the value of the variable x at the point given in the code? public static int mysteriousmethod(int z) { int x = 2+z; return 4*x; } public static void main(String[] args) { int y = 3; int answer = mysterious Method(y); // what value does x have here? } Ox = 20 Ox= 3 Ox is not defined Ox=5
use the same code. but the code needs some modifications. so
use this same code and modify it and provide a output
Java Program to Implement Merge Sort import java.util.Scanner Class MergeSort public class MergeSort Merge Sort function / public static yoid sortfintfl a, int low, int high) int N-high-low; if (N1) return; int mid- low +N/2; Il recursively sort sort(a, low, mid); sort(a, mid, high); I/ merge two sorted subarrays int] temp new int[N]; int i- low, j-mid; for...
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?
JAVA question For the following code, remember to make a table to keep track of the various x y z values. public class Mystery6 { public static void main(String[] args) { int x = 1; int y = 2; int z = 3; z = mystery(y, x, y); // Statement 1 System.out.println(x + " " + y + " " + z); // Statement 2 x = mystery(z, y, x); // Statement 3 System.out.println(x + " " + y +...