Hi the code to answer exercise 71 is below However it is inc

Hi, the code to answer exercise 7.1 is below. However, it is incorrect because \"The incorrect value 56 was found in thearray[6] (should be 55).\" Please edit the code below so that the value 55 is found in thearray[6].

tempvar = thearray[6];

thearray[11] = thearray[6];

thearray[6] = tempvar;

Solution

//using a variable tempvar, store value of array in slot 6
tempvar = thearray[6];

// now we have, value of array in slot 6 stored in a temporary variable which can be used later, //assign value of array in slot 11 to slot 6
thearray[6] = thearray[11];

// finally use the temporary variable tempvar to set the value of array in slot 11, i,e assigning tempvar to array in slot 11
thearray[11] = tempvar;

The values stored in slots 6 and 11 of the array are swapped.

Hi, the code to answer exercise 7.1 is below. However, it is incorrect because \

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site