|
INTERVIEW QUESTIONS
C++
VARIABLES IN C++
DETAILS
Question: How do you decide which integer type to use?
Answer: 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.
|
|
|
Category |
Variables in C++ Interview Questions & Answers -
Exam Mode /
Learning Mode
|
Rating |
(0.2) By 6779 users |
Added on |
9/16/2014 |
Views |
69482 |
Rate it! |
|
|
Question:
How do you decide which integer type to use?
Answer:
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. Source: CoolInterview.com
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. Source: CoolInterview.com
Answered by: vijay kumar | Date: 6/7/2010
| Contact vijay kumar
If you have the better answer, then send it to us. We will display your answer after the approval.
Rules to Post Answers in CoolInterview.com:-
- There should not be any Spelling Mistakes.
- There should not be any Gramatical Errors.
- Answers must not contain any bad words.
- Answers should not be the repeat of same answer, already approved.
- Answer should be complete in itself.
|
|
Related Questions |
View Answer |
|
What is the difference between declaration and definition?
|
View Answer
|
|
What is an algorithm (in terms of the STL/C++ standard library)?
|
View Answer
|
|
what are auto static variables and auto extern variables?
|
View Answer
|
|
How is static variable stored in the memory? ( if there are 2 functions in a file,and the static variable name is same (ex var) in both the function. how is it keep seperately in the memory).
|
View Answer
|
|
What is difference between followin intialization.
int iVar1; int iVar2 = int();
and which one of two should we prefer always and why?
|
View Answer
|
|
I was trying to use an "out int" parameter in one of my functions. How should I declare the variable that I am passing to it?
|
View Answer
|
|
When you inherit a protected class-level variable, who is it available to?
|
View Answer
|
|
Are private class-level variables inherited?
|
View Answer
|
Please Note: We keep on updating better answers to this site. In case you are looking for Jobs, Pls Click Here Vyoms.com - Best Freshers & Experienced Jobs Website.
View All Variables in C++ Interview Questions & Answers - Exam Mode /
Learning Mode
|