193k views
5 votes
Define a function UpdateTimeWindow() with parameters timeStart, timeEnd, and offsetAmount. Each parameter is of type int. The function adds offsetAmount to each of the first two parameters. Make the first two parameters pass by pointer. Sample output for the given program:

User Cybran
by
3.5k points

1 Answer

2 votes

Answer:

Here is a UpdateTimeWindow() method with parameters timeStart, timeEnd, and offsetAmount

// the timeEnd and timeStart variables are passed by pointer

void UpdateTimeWindow(int* timeStart, int* timeEnd, int offsetAmount){

// this can also be written as *timeStart = *timeStart + offsetAmount;

*timeStart += offsetAmount; //adds value of offsetAmount to that of //timeStart

// this can also be written as *timeEnd = *timeEnd + offsetAmount;

*timeEnd += offsetAmount; } //adds value of offsetAmount to that of //timeEnd

Step-by-step explanation:

The function has three int parameters timeStart, timeEnd, and offsetAmount.

First two parameters timeStart and End are passed by pointer. You can see the asterisk sign with them. Then in the body of the function there are two statements *timeStart += offsetAmount; and *End+= offsetAmount; in these statements the offsetAmount is added to the each of the two parameters timeStart and timeEnd.

Define a function UpdateTimeWindow() with parameters timeStart, timeEnd, and offsetAmount-example-1
User FlavienBert
by
3.4k points