Question

In: Computer Science

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;
    }
}

Solutions

Expert Solution

The value of n after this code runs is : 2

Proof :

In C language :


Related Solutions

1. What will be the value of numbers[1] after the following code is executed? int[] numbers...
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 f2 (int n) j = 0; while (j <n) {for (int i = 0; i...
int f2 (int n) j = 0; while (j <n) {for (int i = 0; i <n; ++ i) {cout << "j =" + j; j = j + 5; }}
Please explain this code line by line void printperm(int *A,int n,int rem,int j) {    if(n==1)...
Please explain this code line by line void printperm(int *A,int n,int rem,int j) {    if(n==1)       {        for(int k=0;k<j;k++)        cout<<A[k]<<" + ";        cout<<rem<<"\n";        return;       }     for(int i=0;i<=rem;i++)    {          if(i<=rem)          A[j]=i;          printperm(A,n-1,rem-i,j+1);    } }
int value = 1; do { if (value % 2 == 0) cout << value <<...
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...
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...
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.
1)What is the output of the following code? struct someType { int a; int b; };...
1)What is the output of the following code? struct someType { int a; int b; }; void f1(someType &s) { s.a = 1; s.b = 2; } someType f2(someType s) { someType t; t = s; s.a = 3; return t; } int main() { someType s1, s2; f1(s1); s2 = f2(s1); cout << s1.a << '-' << s1.b << '-' << s2.a << '-' << s2.b << '-' << endl; return 0; } ------------------------------------------------------------------------------------------------------------------ 2) struct dateType { int...
Find the value of ∑(−1)^n/(3n+1) from n=0 to ∞
Find the value of ∑(−1)^n/(3n+1) from n=0 to ∞
What is the ouput of the following code? void loop(int num) { for(int i = 1;...
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; }
[after §3.22 − easy] String Processing : Consider the following code fragment: 1 int a =...
[after §3.22 − easy] String Processing : Consider the following code fragment: 1 int a = 20; 2 int b; 3 double x = 3.5; 4 String s = "All"; 5 char ch; 6 7 x += a; 8 x--; 9 a /= 4 - 1; 10 b = s.length(); 11 b += 4; 12 s += "is well"; 13 ch = s.charAt(b); 14 System.out.println("a = " + a + ", b = " + b); 15 System.out.println("x = "...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT