Consider carefully the program fragment below:
int items = 5;
...
if (items/2 == 2.5)
cout << "items = 5\n";
else
cout << "items != 5\n";
What is its output?
Depends on the value of a at the time of execution of the if clause
item=5
item != 5
None of the Above
The Answer is none of the above.
==========================================
Actually the output of the code is items=5.,But in options its given item=5.
so the answer will be none of the above.
If it is irrespective of item or items then the answer is item=5
Consider carefully the program fragment below: int items = 5; ... if (items/2 == 2.5) cout...
Consider the following pseudo-code fragment. What is the value of mystery(2, 3)? BEGIN PROGRAM mystery(int a, int b) IF (b==1) RETURN a END IF ELSE RETURN a + mystery(a, b - 1) END ELSE END PROGRAM mystery 2 4 6 8 the program generates a run time error (infinite recursion) I have no idea
C++ Program What is the output of the following code fragment?(beta is of type int.) beta = 5; do { switch (beta) { case 1: cout <<'R'; break; case 2: cout case 4: cout << 'O'; break; case 5: cout << 'L'; } beta--; }while (beta>1); cout <<'X';
or (int i - 3; i<ll; i-i+2) Solution: cout< iend; i-i2 B) What will the following program fragment output? (2 points) int mainc int j 7, d 2; double sum 0; 5 Solution: sumd; --ji 9 10 cout<esum; 12 13
31. The following code segment is syntactically correct: int number{20}; cout << number << setbase(16) << " " << number << setbase(10) << " " << number << showpos << " " << number << endl; T__ F__ 32. The following statement wants to determine if ‘count’ is outside the range of 0 through 100: if (count < 0 && count > 100) T__ F__ 33. There is...
Consider the following C++ program: #include <iostream> #include <cstdlib> using namespace std; int main int n =0; int i = 0; cout << "Please enter a strictly positive number:"; cin >> n if (n <= 0) exit(EXIT_FAILURE) while (n > 1) n-n/2; i << endl; cout"Output:" return 0; Answer the following questions: What is the output of the program for each of the following values of n: -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9? What does...
Consider the following program: # include <iostream> int x = 3, y = 5; void foo(void) { x = x + 2; y = y + 4; } void bar(void) { int x = 10; y = y + 3; foo( ); cout << x << endl; cout << y << endl; } void baz(void) { int y = 7; bar( ); cout << y << endl; } void main( ) { baz( ); } What output does this program...
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...
Consider the following program: # include <iostream> using namesapce std; void Func(int a, int bl double number-25.0: int main) f int x-18, y-20; cout<c"Before: x- kex<" and y-eyecendl; Fundxy 1// end of main void Funcfint a, int b) int sum a+b; a-200; b-300; numberanumber+1.0 Which of the statements below are correct? (Select only the correct answers. There may be more than one) D A The statement double number-25.0; declares a global variable number B. The variables x and y are...
Examine each of the following program segments carefully. Determine what is printed from each program. There are no intentional errors. 1. int array[] = {1, 2, 3, 4, 5}; for (int i = 0; i < 5; i++) cout << array[i]*5 << “ “; Output _________________________________ 2. int *iptr; iptr = new int[5]; for (int count = 0; count < 5; count++) iptr[count] = count+1; cout << *iptr << endl; Output _________________________________ 3. int x = 50, y = 60,...
11.3 What is the correct output from the following program? int A, B; A = 6; B = 1; if (A > B) { A = B + A * 2; B ++; } else { A = A % 2; B = B + 4; } cout << "A = << A << "B = " << B; Select one 0 2 A=8B-2 O b. A=B=5 c None of the above is correct d A-13 B= 2