Which of the following type of variable is visible only within a function where it is defined?
A: global variable
B: local variable
C: Both of the above.
D: None of the above.
A: global variable
B: local variable
C: Both of the above.
D: None of the above.
举一反三
- A variable defined in the main () function is called a global variable.
- Of which the initial value is unpredictable, if it is not initialized? A: static external variable B: local variable C: static local variable D: external variable
- Which one of the following statements is right? A: If a local variable has static storage duration, its lifetime will be extended. B: If a global variable has static storage duration, its scope will be expanded. C: A variable will have an unpredictable value before initialization; no matter it has static storage duration or automatic storage duration. D: The storage type descriptors which formal parameter can use are exactly the same as that used by the local variables.
- Use the following code to answer the following questions: int id = 0; cout [< "ID: "; cin ]> id; if (id == 1) cout << "Janet"; else if (id == 2 || id == 3) cout << "Mark"; else if (id == 4) cout << "Jerry"; else cout << "Sue"; (1) The above code display ____when the id variable contains the number 2? (2) The above code display ____when the id variable contains the number 4? (3) The above code display ____when the id variable contains the number 3? (4) The above code display ____when the id variable contains the number 8
- After constructing a new factory, the cost of building the factory is a A: past cost. B: sunk cost. C: variable cost. D: None of the above answers are correct.