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); }
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
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.
(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.
Utility function over clothing (C) and greens (G) is defined by the function U(C,G)=C^(1/4)+G^(1/4). Let P(of...
Utility function over clothing (C) and greens (G) is defined by the function U(C,G)=C^(1/4)+G^(1/4). Let P(of C) and P(of G) denote the prices of cherries and grapes respectively. W is income that is available to consumer to spend on those two goods. (a) Write down the customer's utility maximization problem. (b) set up the langrangian and solve for the first order condition. (c) Solve for the consumer's demand functions for clothing and greens. Please Explain.
4. Let n ≥ 8 be an even integer and let k be an integer with...
4. Let n ≥ 8 be an even integer and let k be an integer with 2 ≤ k ≤ n/2. Consider k-element subsets of the set S = {1, 2, . . . , n}. How many such subsets contain at least two even numbers?
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT