CPP Variables MCQCpp MCQ
(1) Global variables are created in:
C) Hard disk
All type of variables including global variables are created in main memory called RAM. These variables are different in their lifetime and access.
(2) Which of the following variable type can be accessible anyway in the program
Global variables are created outside of the main() function and can be accessible in entire program.
(3) Which of the following type of variables hold their data throughout the program executioner
D) Both b and c
Static and global variables hold their data throughout the lifetime of program execution. The difference between global and static variables is that global variables are accessible throughout the entire program while static variables can only be accessible inside function where these are created.
(4) Which of the following default storage class specifier for declaring local variables?
Auto storage class specifier is the default for declaring local variables. We can write it before declaration of local variables. If auto kwyword is not used then variables are by default declared as local.
(5) How many types of variables can be created in C/C++ programs
There are four types of variables that can be created in C/C++. These are Global, Local, Static and Register. Most commonly local variables are created in programs.
(6) Which of the following type of local variable retain its value throughout program execution
Static variables are local variable that are declared inside function body. These variables are created at first function call and retain their value throught the lifetime of program.
(7) Variable has the following properties
D) All of These
Name, Address, Type and Value are four properties of variable.