MCQ IN COMPUTER SCIENCE & ENGINEERING

COMPUTER SCIENCE AND ENGINEERING

ALGORITHMS

Question [CLICK ON ANY CHOICE TO KNOW THE RIGHT ANSWER]
What is a variable?
A
A named location in memory that stores information that cannot change
B
A named location in the CPU that stores information that can change
C
A named location in memory that stores information that can change
D
A numbered location in memory that stores information that cannot change
Explanation: 

Detailed explanation-1: -A variable is a named memory location which temporarily stores data that can change while the program is running. A constant is a named memory location which temporarily stores data that remains the same throughout the execution of the program. The type of a variable indicates what kind of value it will store.

Detailed explanation-2: -Variables are usually stored in RAM. This is either on the heap (e.g. all global variables will usually go there) or on the stack (all variables declared within a method/function usually go there). Stack and Heap are both RAM, just different locations. Pointers have different rules.

Detailed explanation-3: -A variable is the name of a memory cell. It is “variable” because the value in the cell can change. Each memory cell has an address. Python and other high-level languages use a symbol table to map a variable name to the address it represents.

Detailed explanation-4: -A variable is a data item whose value can change during the program’s execution.

Detailed explanation-5: -Identifiers are descriptive names that are mapped to locations in the computer’s memory. Once a memory location is given a specific name, we can refer to that location using the identifier rather than the numeric address.

There is 1 question to complete.