What is the value of n after this code runs?
1 Point
int n = 0;...
What is the value of n after this code runs?
1 Point
int n = 0;
int j = 7;
if ((j!=0) && (n < 25))
{
n = 1;
if (j > 4)
{
n = 2;
}
else
{
n = 3;
}
}
else
{
n = 4;
if (j%2 >= 2)
{
n = 5;
}
else
{
n = 6;
}
}
1. What will be the value of numbers[1] after the following code
is executed?
int[] numbers = {22, 33, 44};
for(int k = 0; k < 3; k++)
{
numbers[k] = numbers[k] + 5;
}
}
2. What will be the results of the following code?
final int ARRAY_SIZE = 5;
double[] x = new double[ARRAY_SIZE];
for(int i = 1; i <= ARRAY_SIZE; i++)
{
x[i] = 10.0;
}
3.What is the value of numbers [3] after the following line...
int value = 1;
do
{
if (value % 2 == 0)
cout << value << " ";
value = value + 1;
}
while (value % 7 != 0);
cout << "\n" << value;
What will be displayed?
Consider the following C code that outlines Fibonacci
function
int fib (int n) {
if (n == 0) return 0;
else if (n==1) return 1;
else return fib(n-1) + fib (n-2);
}
For this programming assignment, write and test an ARMv8 program
to find Fibonacci (n).
You need to write a main function that calls the recursive fib
function and passes an argument n.
The function fib calls itself (recursively) twice to compute
fib(n-1) and fib (n-2). The input to...
In Java:
int[] A = new int[2];
A[0] = 0; A[1] = 2;
f(A[0],A[A[0]]);
void f(int x, int y) {
x = 1; y = 3;
}
For each of the following parameter-passing methods, saw what
the final values in the array A would be, after the call to f.
(There may be more than one correct answer.)
a. By value. b. By reference. c. By value-result.
What is the ouput of the following code?
void loop(int num)
{
for(int i = 1; i < num; ++i)
{
for(int j = 0; j < 5; ++j)
{
cout << j;
}
}
}
int main()
{
loop(3);
return 0;
}