How many assignment operators occur For the following code s

How many assignment operators occur?

For the following code, suppose the if statement is true 50% of the time. If so, how many assignment operations occur? (Don\'t forget to count the initializations of i and j. Also remember that i++ and j++ are assignments.) for (int i = 0; i

Solution

Int i=0    = 1 time

I++         =100 times

Int J=0 =100 times

J++         =100X100 =10000 times

If statement true for 50 %

Inside if(arr[j]<arr[i])

Three assignments operations

So 150 assignments

100X150=15000 assignments

Total :

Int i=0                              = 1          time

I++ = 100       times

Int J=0                            = 100       times

J++ = 10000    times

Inside if(arr[j]<arr[i]) = 15000    times

________________________________________

Total =25201   assignment operations

How many assignment operators occur? For the following code, suppose the if statement is true 50% of the time. If so, how many assignment operations occur? (Don

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site