Without Book Interview Questions and Answers | Online Test | Moct Test
Download Android App in your Android Device from Google Play Store
- Search for "Withoutbook Practice Exam Test" in Mobile/Tablet Play Store
Institute Training Search by Name or Email

Exams Attended

Make Homepage

Bookmark this page

Subscribe Email Address

C++ Interview Questions and Answers

Ques 56. How do you decide which integer type to use?

Ans.
It depends on our requirement. When we are required an integer to be stored in 1 byte (means less than or equal to 255) we use short int, for 2 bytes we use int, for 8 bytes we use long int.

A char is for 1-byte integers, a short is for 2-byte integers, an int is generally a 2-byte or 4-byte integer (though not necessarily), a long is a 4-byte integer, and a long long is a 8-byte integer.

Is it helpful? Add Comment View Comments
Ques 57. What does extern mean in a function declaration?
Ans. Using extern in a function declaration we can make a function such that it can used outside the file in which it is defined.

An extern variable, function definition, or declaration also makes the described variable or function usable by the succeeding part of the current source file. This declaration does not replace the definition. The declaration is used to describe the variable that is externally defined.

If a declaration for an identifier already exists at file scope, any extern declaration of the same identifier found within a block refers to that same object. If no other declaration for the identifier exists at file scope, the identifier has external linkage.
Is it helpful? Add Comment View Comments
Ques 58. What can I safely assume about the initial values of variables which are not explicitly initialized?
Ans.
It depends on complier which may assign any garbage value to a variable if it is not initialized.
Is it helpful? Add Comment View Comments
Ques 59. What is the difference between char a[] = ?string?; and char *p = ?string?;?
Ans.
In the first case 6 bytes are allocated to the variable a which is fixed, where as in the second case if *p is assigned to some other value the allocate memory can change.
Is it helpful? Add Comment View Comments
Ques 60. What?s the auto keyword good for?
Ans.
Answer1
Not much. It declares an object with automatic storage duration. Which means the object will be destroyed at the end of the objects scope. All variables in functions that are not declared as static and not dynamically allocated have automatic storage duration by default.

For example
int main()
{
int a; //this is the same as writing ?auto int a;?
}

Answer2
Local variables occur within a scope; they are ?local? to a function. They are often called automatic variables because they automatically come into being when the scope is entered and automatically go away when the scope closes. The keyword auto makes this explicit, but local variables default to auto auto auto auto so it is never necessary to declare something as an auto auto auto auto.
Is it helpful? Add Comment View Comments

3) What can I safely assume about the initial values of variables which are not explicitly initialized? 4) What is the difference between char a[] = ?string?; and char *p = ?string?;? 5) What?s the auto keyword good for? " />

Most helpful rated by users:

©2016 WithoutBook