What does the computer do when it executes a variable declaration statement?

Q14. What does the computer do when it executes a variable declaration statement? Give an example.

Ans. A variable is a box, or location, in the computer’s memory that has name. The box holds a values of some specified type. A variable declaration statement is a statement such as

int x;

which creates the variable x. When the computer excutes a variable declaration, it creates the box in memory and associates a name (in this case, x) with that box. Later in the program, that variable can be referred to by name.

 

Leave a Reply

Your email address will not be published. Required fields are marked *