130k views
1 vote
Write a declaration for floating-point variable lastVal that’s to retain its value between calls to the function in which it’s defined.

User Elim
by
4.9k points

1 Answer

3 votes

Answer:

The following are the variable declaration to this question:

static float lastVal;

Step-by-step explanation:

In the question, it is already defined that a method is defined and inside the method a "lastVal" a float variable is declared that uses the static keyword, which means throughout the program its value can't be changed, and throughout the program, it's one copy is generated, and Inside the method, its declaration does not use such a variable, it only works locally.

User Mpb
by
5.0k points