Question

In: Computer Science

2. Let the function fun be defined as int fun(int*k) {       *k += 4;       return...

2. Let the function fun be defined as

int fun(int*k) {
      *k += 4;
      return 3 * (*k) - 1;
}

Suppose fun is used in a program as follows:

void main() {
      int i = 10, j = 10, sum1, sum2;
      sum1 = (i / 2) + fun(&i);
      sum2 = fun(&j) + (j / 2);
}

What are the values of sum1 and sum2

a. operands in the expressions are evaluated left to right?

b. operands in the expressions are evaluated right to left?

Solutions

Expert Solution


Related Solutions

Let S = {2 k : k ∈ Z}. Let R be a relation defined on...
Let S = {2 k : k ∈ Z}. Let R be a relation defined on Q− {0} by x R y if x y ∈ S. Prove that R is an equivalence relation. Determine the equivalence class
Suppose A is (10, 2, 5, 9, 1, 8, 2, 4). Consider the function: int BBOX(int...
Suppose A is (10, 2, 5, 9, 1, 8, 2, 4). Consider the function: int BBOX(int n, int k)             if (n <= 0) return 0;             else if (A[n] < k) return (1+ 2*BBOX(n-1,k+1));             else return BBOX(n-1,k-2);             Find BBOX(8, 5)
Let M be defined as follows M = (K, Σ, s, ∆, F ) for K...
Let M be defined as follows M = (K, Σ, s, ∆, F ) for K = {q0, q1, q2, q3, }, s = q0, Σ = {a, b, c}, F = {q0, q2, q3} and ∆ = {(q0, abc, q0), (q0, a, q1), (q0, e, q3), (q1, bc, q1), (q1, b, q2), (q2, a, q2), (q2, b, q3), (q3, a, q3)}. 1. (1pts) Draw the diagram of M 2. (6pts ) DRAW a diagram of an automata M0 such...
#include <stdio.h> #include <math.h> int fun(int); int main(void)    {     int i = 5, x...
#include <stdio.h> #include <math.h> int fun(int); int main(void)    {     int i = 5, x = 3;     i = fun(x);     printf("%d\n", i);     return 0; } int fun(int i) {      int res = 0;      res = pow (i , 3.0);      return ( res); }
Let k be an integer satisfying k ≥ 2. Let G be a connected graph with...
Let k be an integer satisfying k ≥ 2. Let G be a connected graph with no cycles and k vertices. Prove that G has at least 2 vertices of degree equal to 1.
import java.util.*; class A { int i, j, k; public A(int i, int j, int k)...
import java.util.*; class A { int i, j, k; public A(int i, int j, int k) { this.i=i; this.j=j; this.k=k; } public String toString() { return "A("+i+","+j+","+k+")"; } } class Main { public static void main(String[] args) { ArrayList<A> aL=new ArrayList<A>(); Random rand= new Random(1000); //1000 is a seed value for (int p=0; p<10; p++) { int i = rand.nextInt(100); int j = rand.nextInt(200); int k = rand.nextInt(300); aL.add(new A(i, j, k)); } System.out.println("----- Original arraylist------"); for (A a: aL)...
determine the range and domain of the following: the function k defined by k(x)= square root...
determine the range and domain of the following: the function k defined by k(x)= square root x-3
a) Let T(n) be a running time function defined as T(n) = 3n^2 + 2n +...
a) Let T(n) be a running time function defined as T(n) = 3n^2 + 2n + 5, is this ϴ(n^2 )? Explain prove your answer using the definitions of big-o and omega notations. b) Solve the following recurrence relations using Master theorem. a. ?(?) = 3? ( ?/3 ) + ? b. ?(?) = 5?( ?/2 ) + 2?^2 please help them with both
(a). Let S be the surface defined by x^4 − 3x^2y^2 + 4z^2 = 17. Find...
(a). Let S be the surface defined by x^4 − 3x^2y^2 + 4z^2 = 17. Find the equation of the tangent plane to the surface S at (1, 0, 2). (b) Let f(x,y) = e^2xy . Let P = (2,0) and Q = (3,2). Find the directional derivative of f at P in the direction of PQ.
Programmer defined Function / Arrays: 1.Write a function for printing an array. void print_array (int arr[],...
Programmer defined Function / Arrays: 1.Write a function for printing an array. void print_array (int arr[], int size); 2. Write a function to generate an array of random integers. void random_array (int arr[], int size, int range); The scale of numbers should be 1 to range. 3. Write a function to find the sum of a sequence of number. int sum (int arr[], int size); 4. Write a function rotate(arr[], d, n) that rotates arr[] of size n by d...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT