| 1. |
Give One Real Time Application Where Static Variables Are Used? |
|
Answer» Thinks of a situation where you need to do some work just once in a function irrespective of how many times that function is INVOKED then U can have a static variable which will keep a track of it. EG int main () { static int once = 0; if (!once) { once++; /*code need to be executed once*/ } /*RESET of the code*/ } Thinks of a situation where you need to do some work just once in a function irrespective of how many times that function is invoked then u can have a static variable which will keep a track of it. eg int main () { static int once = 0; if (!once) { once++; /*code need to be executed once*/ } /*reset of the code*/ } |
|