Question: Q 1 1 . Consider: void f ( int * v , int len, int * x ) { int sum = 0 ; for

Q11.
Consider:
void f(int* v, int len, int* x){
int sum =0;
for (int i =0; i < len; i++){
sum += v[i]%2;
}
*x = sum;
}
int vec[]={1,2,3,4,5};
int x[1];
int* y = x;
f(vec, sizeof(vec)/sizeof(int), y);
What is the value of *y?
Q12.
Multithreading: Concurrency.
Consider the following code runs in a multi-threaded environment:
uint64_t counter;
void incrementVariable()
{
counter++;
}
If the initial value of counter was 100, what are the possible values of counter after calling incrementVariable() from 2 different threads? Each of the two threads calls the function exactly one time.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Finance Questions!