Multiple choice

A static variable is

  1. a variable, the value of which keeps on changing through out the program

  2. a variable, the value of which increase in a uniform order

  3. a variable, the value of which decreases constantly

  4. a variable, the value of which remains constant through out the program

Reveal answer Fill a bubble to check yourself
D Correct answer
Explanation

A static variable in C++ retains its value between function calls and is initialized only once. It exists for the entire program duration, maintaining its value throughout execution. Unlike automatic variables, static variables do not get re-initialized on each function call.