g. Output is 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 h. Output is 11 12 i. Output is 9 j. Output is 10 9 8 7 6 5 4 3 2 1
what is the output of the following code segment? C++ g. int arr[3][4]; for (int i...
Consider the following C++ code segment: for (int i = 0; i <n; ++i) { for (int j = 0; j <m; ++j) if (i != j) cout << "0"; else cout << "1"; } } Which of the options below gives the correct output if the value of nis 2and the value of mis 3? 1. 100010 2. 011101 3. 100100 4. 010001
give the output of the codes in C++ int g(int x) { int tmp = x + 1; return x* tmp; int fint x, int y) { X += Y; return g(x); int main() { int x = 3; cout << g(x) << endl; cout << f(x, 1) << endl; cout << f(x, 2) << endl; int intVar = 24.2/2; cout<<intVar; Int main() int Enter = 1; switch (Enter) case 1: Enter = -4; case 2: Enter = -6; case...
(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...
points): Show the output of the code below as it would appear on the monitor. int main cout <<" <<endl: int wildcat 2: while (wildcat > 5) cout << wildcat <<endl; wildcat++ cout <K*<< endl; int jayhavk 5i do cout << jayhawk <s endl: while (jayhawk0) cout <<*" << endl; int wolverine l: while (wolverine 0 &&wolverine < 10) cout << wolverine <<endl: wolverine2: cout <<" <<endl: for (int zag-4; zag>0; zag_) cout <<****" << endl; for (int i-10; i<-30;...
Question 28 What is the output of the following program? Assume code is correct. #include <iostream> using namespace std; int main() { int i = 1,j,x = 5, y = 4; while (i <= y) { for (j = 0; j <= y2; j++) cout << 'Z'; cout << endl; i=i+1; } return 0; 3 B IV AA-I E333 X X, B, GT 12pt Paragraph
howthe output of the following 4 program segments (a) const int SIZE=8; int values[SIZE] = {10, 10, 14, 16, 6, 25, 5, 8}; int index; index=0; res = values[index]; for (int j=1; j<SIZE; j++) { if (values[j] > res) { res = values[j]; index = j; cout << index << res << endl; } } cout <<...
Consider the following code segment. int[]arr={1, 2, 3, 4, 5, 6, 7, 8}; for(int k=3; k<arr.length-1; R++ arr[k]-arr[k+1]; What are the contents of arr as a result of executing the code segment? a. {1, 2, 3, 5, 6, 7, 8, 8) b. {2, 2, 4, 5, 6, 7, 8, 8} C. {2, 4, 6, 5, 6, 7, 8,8} d. {4, 2, 4, 4, 6, 7, 8, 8) e. {6, 6, 4, 5, 6, 7, 8, 8} int) arr={7, 2.5, 3.0,...
int arr[] = {1,4, 1, 0); for (int i=0; i < 4; ++i) cout<<arr[i]*2; 0140 1014 1410 (space in between each number) 1410 None of the above void square(int &n){n= n*n;} int arr[] = {1, 2, 3}; int number = 4; Which of the following function calls are acceptable? square(1); square(arr[number]); square(number); square(2);
18 C++ 1. What is the output of the following program segment? int y-22: while ((y 3) != 0) cout << y<< "": y=y-2; The output is 2. Suppose that the input is 100, 20,-8, 50, 20. What is the output of the following C++ code? int sum0 int num: int j cin >> num: if (num < 0) continue зит зит + num; cout<< sum << endl; The output is
in c++ #include <iostream> using namespace std; int main() int beta[7] = 3, 5); for (int i = 2; i < 7; i++) beta[i] = 3 * i + 2; beta[i - 1] = beta[i - 1] + beta[i]; beta[i - 2) = betali - 2] + beta (i - 1]; for (int i = 0; i < 7; i++) cout << beta[i] << " "; cout << endl; return 0;