#include<iostream>
using namespace std;
int main()
{
int x=40;
if(x>25)
{
x=x*2;
} //Here x=40,so 40>25,now x=40*2=80 then
x=80..
if(x>0)
{
x=x+1;
} //Here x=80,so 80>0,now x=80++1 then x=81.
else
{
x=x-1;
}
cout<<"x="<<x<<"\n"; //Final value
of x is 81..
}
C++ READ CODE: 8. Below is a code fragment; assume x is an integer with the...
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;
Write this code in c++ and screen shot the code
2. Given the code below: int vals t1 (4.7,11). valPtr valPtr-vals What is the output of the following statements, if it is an address, indicate that: a. cout (1valPtr) F c. cout << (valPtr2); e. cout <<*(valPtr0) cout << "True" cout << "False" cout << "True" cout << "False" cout << "True" cout << "False", ㄱ Hip else g. if (valPtr&valPtr [1]) else h. if (valPtr (4] &valPtr [1]) else
What is the output of the following code fragment? int i = 1; while( i <= 5 ) if(i == 2 || i == 4) System.out.println(i + ":" + " is an even index) System.out.println("i: " + i); i++;
Consider the following C++ code segment: if (i j) cout << "1"; else if ((i &j) < 3) cout << "2"; else if (i < (j-1)) cout << "3"; else cout << "4"; cout << "5"; If the value of iis 5and the value of jis 6, which of the options below gives the correct output? 1. 25 2. 35 3. 15 4. 45
3) What are the final values of a, b, c in the following code fragment (1.5 point): int a = 6 , b = 127 , c; c = ( ++a ) + ( b -- ); Answer: 4) What are the final values of a, b, c in the following code fragment (1.5 point): int a = 6 , b = 127 , c; c = (a++) + ( -- b); Answer: 5) What is displayed by this poorly...
Write C++ code that creates an integer variable called number.
Dereference a given pointer gPointer and places that value into the
variable number. The pointer gPointer will have been declared and
set to point to a value before your code runs. Your code will be
placed inside the main function with all the appropriate #includes.
After your code runs, the test case will execute the following
code: cout << "number = " << number << endl; For
example: Test Result...
What is the software bug, and how do you fix the issue for the code fragment below? #include <iostream> #include <limits> using namespace std; int main() { int x; //find the maximum integer value and avoid an overflow int imax = std::numeric_limits ::max(); cout <<"Enter a value for x: "; cin >> x; if (x > imax) cout << "overflow\n"; else cout << x; return 0; }
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...
Explain specifically what error. You may assume all includes are done properly, the code is inside a valid function, assume "srand(time(0)):" has been set int x[5]; int sum; for(int 1-0 ; i <= 5; i++); x[i] sum = rand ( ) %100 ; x[i]; cout < "Sum is: "<<sum << endl;
Consider the following method. public static ArrayList<Integer mystery(int n) ArrayList<Integer seg - new ArrayList<IntegerO; for (int k = n; k > 0; k--) seq.add(new Integer(k+3)); return seq What is the final output of the following Java statement? System.out.println(mystery(3)); a. [1,2,4,5) b. [2,3,4,5) c. [6,5,4,3] d. [7, 7, 8, 8] e. [7,8,9, 8) O Consider the following method: public static int mystery(int[] arr, int k) ifk-0) return 0; }else{ return arr[k - 1] + mystery(arr, k-1):) The code segment below is...