Write the definition of a function named counter that receives no parameters and returns 0 the first time it is invoked, returns 1 the next time it is invoked, then 2, 3 and so on.

Respuesta :

ijeggs

Answer:

int counter( )

{

static int xvalue = 0;

return(xvalue++);

}

Explanation:

The first line of code declares the function and its return type integer. Then we create a static variable xvalue and initialize to 0. the statement return(xvalue++) ensures that at each method call, the value of integer is increased by 1