Whats the value of y after executing the following snippet in c++
int x = 0, y = 15;
if (x=20)
y +=x;
= is an assignment statement So, x=20 always true then y += x y = y + x y = 15 + 20 y = 35 y after executing the following snippet in c++ is 35
35
Whats the value of y after executing the following snippet in c++ int x = 0,...
What is the value of n after the following snippet? int n = 13, m = 16; int* np = &n; np = &m; *np = 10; O 16 O 10 O A memory address O 13 True or False? This snippet correctly frees the memory it allocates. int** nums = new int*[10]; for (int i = 0; i < 10; i++) { nums[i] = new int; for (int i = 0; i < 10; i++) { delete nums[i]; delete...
51. What is the output of the following code snippet? int number = 0; int ptr_num -&number ptr_num 60; number-80 cout < "ptr num << endl b, 60 c. 80 d. the address of number Answer 52. What is the output of the following code snippet? double num-0.0; double* ptr = # num = 15.0; ptr ptr 15.0 cout << num <<"ptr <<endl; a. 15 15 b. 15 30 С. 30 15 d. 30 30 Answer: 53. What is the...
6) What is the final value of variable num after executing the following statements? void Exam(int & N) A)13 ( T++ ¢ut << < 1 ) B)12 void main() (int num-10; C) 11 for (int i - 0; i < 3; i.) Exam (num). D) 10
QUESTION 1 What is the output of the following code snippet? int main() { bool attendance = false; string str = "Unknown"; attendance = !(attendance); if (!attendance) { str = "False"; } if (attendance) { attendance = false; } if (attendance) { str = "True"; } else { str = "Maybe"; } cout << str << endl; return 0; } False True Unknown Maybe QUESTION 2 What is the output of the following code snippet? #include <iostream> #include <string> using...
1. Given this snippet of codes, what is the expected output? void func(int *x, int y) { *x = *x + y; y = 2; } void main() { int x = 10, y = 10; func(&x, y); printf("x: %d, y: %d", x, y); } x= ? y=? 2. Given this snippet of codes, what is the expected output? void func(int *x, int y) { *x = *x + y; x = 10;...
What is the value of y after the following code is executed? int x = 20, y = 30; do { int z; z = 3 * ( y
c++ question 1. C++ string Class What does the output look like after executing the following statements? std::string numstr = "12"; numstr += "3"; std::cout << numstr << '\n'; A. None of these. B. The snippet has syntax errors. C. 15 D.123 // 2. Let S be a class that allows integers to be stored in its objects like an array. For example, if obj is an object of S, one can write statements like obj[0] = 100; or int...
need help whats the answers numItems and userVal are int types. What is the final value of numItems if userval=3? switch (userval) { case 1: numItems - 5; break; case 3: numItems - 12; break; case 4: num Items - 99 break; default numItems - 55; break; } O 12 55 5 99 istall, isRich, and isFamous are Boolean variables. What is isFamous after executing the following statements? istall - false; Rich = true; inFamous - false; sf (istall &&...
QUESTION 1 What will be displayed as a result of executing the following code? int x = 5, y = 20; x += 32; y /= 4; cout <<"x = " << x <<"y = " << y; A. x = 32, y = 4 B. x = 9, y = 52 C. x = 37, y = 5 D. x = 160, y = 80 8 points QUESTION 2 What will be the displayed when the following code...
What is wrong with the following code snippet? int main() { int width = 10; height = 20.00; cout << "width = " << width << " height = " << height << endl; return 0; } The code snippet uses an uninitialized variable. The code snippet uses an undefined variable. The code snippet attempts to assign a decimal value to an integer variable. The code snippet attempts to assign an integer value to a decimal variable.