==========================================
Solution:
Output of code =
========================================
Explanation:
-----------------------------------------------------------
int x = 7 , y = 10;
In the above line of code , we have declared two integer variables named 'x' and 'y'. And their values as 7 and 10 respectively.
Means that right now x = 7 and y = 10
------------------------------------------------------------
x -= 30;
The above line of code is equivalent to x = x - 30
Means that subtract 30 from x and store the value back into x.
Means that x = 7 - 30
so, now 'x = -23'
--------------------------------------------------------------
y *= 5;
The above line of code is equivalent to y = y * 5
Means that multiply y and 5 and store the value back into y.
Means that y = 10 * 5
so, now 'y = 50'
----------------------------------------------------------
x += 32;
The above line of code is equivalent to x = x + 30
Means that add x and 30 and store the value back into x.
Means that x = -23 + 32
so, now 'x = 9'
------------------------------------------------------
y /= 4;
The above line of code is equivalent to y = y / 4
Means that divide y by 4 and store the value back into y.
Means that y = 50 / 4
so, now 'y = 12' (integer value of 12.5 = 12)
------------------------------------------------------
cout << "y = " << y << " and x = " << x << ";" << endl;
The above line of code is used to print the values of y and x respectively;
It will print 'y = 12 and x = 9'
----------------------------------------------------
x -= 10;
The above line of code is equivalent to x = x - 10
Means that subtract 10 from x and store the value back into x.
Means that x = 9 - 10
so, now 'x = -1'
---------------------------------------------------
y /= 5;
The above line of code is equivalent to y = y / 5
Means that divide y by 5 and store the value back into y.
Means that y = 12 / 5
so, now 'y = 2' (integer value of 2.4 = 2)
-------------------------------------------------------
cout << "x= " << x << " and y = " << y << ";" << endl;
The above line of code is used to print the values of x and y respectively;
It will print 'x = -1 and x = 2'
==========================xxxxxxxx================================
What is the output of the following C++ code? int count = 1; int num = 25; while (count < 25) { num--; count++; } cout << count « " " « num << endl i 25 1 0 24 1 0 25 0 0 24 0 In this while loop statement, while (counter < 10), where counter is an int variable. Which statement below is an equivalent way to write this while statement? while (10 < counter) while (9...
OUTPUT IF: X = 10 Y = -5 X = 5 Y = -5 X = -15 Y = 5 Consider the following code segment, clearly showing a blank with a carat (™). What are the outputs? int x, y; cout << "This summer I am going to learn"; if (x > 10) cout << "swimming,"; else if (y > 0) cout << "surfing." else if (x > 0) cout << "dancing."; if (x <-10) cout << "spinning,"; else cout...
What is the output?
A. What is the output of the following C++ code fragment? (all variables are of type int) int count-1; int y-100; while (count 3) y=y-1 ; count+t cout << y << endl; cout<< count <<endl What is the value of x after control leaves the following while loop? (all variables are of type int) B. int x0 while (x < 20) sum- sum+x cout << sum<< endl;
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
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...
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...
What is the output? (3 pts) int num = 5; int* ptr = # cout << ptr << endl; cout << &ptr << endl; cout << *ptr << endl;
C++ What output does the following program produce? int getValue(int a, int b, int n); int main() cout << getValue(1, 7, 7) << endl; return 0; } // end main int getValue(int a, int b, int n) int returnValue = 0; cout << "Enter: a = " < a << " b = " << b << endl; int c = (a + b)/2; if (C* C <= n) return value = c; else returnValue = getValue(a, C-1, n); cout...
what is the output of the following code segment? C++ g. int arr[3][4]; for (int i = 0; i < 3; i++) for (int j = 0; j < 4; j++) arr[i][j] =i*4 + j; for (int i = 0; i < 3; i++) for (int j = 0; j < 4; j++) cout << arr[i][j] << " "; h. int next(int & x) { x= x + 1; return (x + 1); int main() { int y = 10;...