What is the value of x[2] after execution of this code
fragment?
int x[4] = {3, 6, 9, 5};
x[2] -= x[1] % x[3];
1 |
||
2 |
||
3 |
||
8 |
ANSWER:-
OPTION (D) 8
Explanation:- initialize array of size 4 with four values , int x[4] = {3, 6, 9, 5};
in this statement array indexes hold the value x[0]=3, x[1]= 6, x[2] = 9, x[3] = 5;
so after that initialization exicute the statement x[2] -= x[1] % x[3];
x[2] = x[2] - x[1] % x[3]
x[2] = 9 - 6 % 5
x[2] = 9 - 1
x[2] = 8
What is the value of x[2] after execution of this code fragment? int x[4] = {3,...
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
ed What is the output after execution of the code block {for (int i=1;i<=4; i++) {if (i==3) continue; cout<<"-"<<i; i++}} 1.00 on Select one: a.-1-3 b.-1-2 C.-1-4 O d.-2-3
What is the value of x after the execution of the code snippet. Give an exact answer as a function of N. Justify your answer. x = 0 for J = 1 to N do x = x + 2 end for Using Theta notation, how many bits do you need to represent x after the execution of the code snippet?
What is the value of result after the following code executes? int a = 60; int b = 15; int result = 20; if (a = b) result *= 3; 30 20 60 10 code will not execute The numeric data types in C++ can be broken into two general categories which are integers and floating-point numbers singles and doubles real and unreal numbers numbers and characters numbers and literals Which line in the following program will cause a compiler error?...
What will be the value of x after the following code is executed? int x = 5; while (x <50) { x += 5; } a) 50 b) 45 c) Infiniteloop d) 55 Given the following code segment: Scanner in = new Scanner (System.in); boolean done = false; while (!done) { int input = in.next(); if(input.equalsIgnoreCase("q")) done = false; } What will cause the loop to terminate? a) When the user enters -1 b) The loop will never terminate c)...
( C prog) write an output for the following code fragment int a[]= {1, 2, 3, 4, 5, 6}: int *ip; int i; ip=a; ip +=3; *ip= *ip * 3; for (i=0; i <6; ++i) printf("%d," a[i]);
1. Consider the following java code. int x 5 X++ Give equivalent MIPS ISA. Assume compiler will keep x in $s0 ($16) 2. What will be in $8 after executing the following statements? addi $8, $0, 5 add $8, $8, $8 What will be in $8 after execution? 2. addi $8, $0, 5 sll $8, $8, 2 shifting $8 left twice (logical shift- assume no sign) 4. What will be in $8 after execution? Assume $9 contains a valid RAM...
True/False 1. The results of code fragment sizeof(int*)==sizeof(int) depends on the compiler and architecture. 2. If c is of type int* and b is of type int, c[b] is equivalent to *c+b. 3. Security software focuses on engineering software so that it continues to function correctly under malicious attack. 4. Ethical hacking is about hacking into systems run by those whose ethics you disagree with. 5. Concurrency occurs when two or more separate execution flows are able to run simultaneously.
2. What is the value of x alter the following code is executed # include<iostream> using namespace std; int main int t-0, c- 0,x-3; while (c < 4) t=t+x; cout << x return 0; a) 3 b) 21 c) 24 d) 48 3. What is the output of the following code? # include<iostream> using namespace std; int main0 int a- 3; for (int i 5; i >0; i) a a+i cout << a << “ “ return 0; d) 8...
What will be the value of w after the following section of code executes: int w = 4, 9 = 3; if (a < 5) if (w == 7) W = 3; else W = 3; else if (w > 3) W = 2; else W = 1; Select one 2.3 0 b.o 0.2 d. 1