|
INTERVIEW QUESTIONS
PROGRAMMING LANGUAGES
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 |
C++ Interview Questions & Answers -
Exam Mode /
Learning Mode
|
Rating |
(0.3) By 7167 users |
Added on |
7/16/2015 |
Views |
66363 |
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
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 |
|
Explain which of the following declarations will compile and what will be constant - a pointer or the value pointed at: * const char * * char const * * char * const
|
View Answer
|
|
Why are arrays usually processed with for loop?
|
View Answer
|
|
What’s the output of the following program? Why? #include <stdio.h> main() { typedef union { int a; char b[10]; float c; } Union;
Union x,y = {100}; x.a = 50; strcpy(x.b,"hello"); x.c = 21.50;
printf("Union x : %d %s %f
",x.a,x.b,x.c ); printf("Union y :%d %s%f
",y.a,y.b,y.c); }
Given inputs X, Y, Z and operations | and & (meaning bitwise OR and AND, respectively) What is output equal to in
|
View Answer
|
|
What does extern mean in a function declaration?
|
View Answer
|
|
How do I declare an array of N pointers to functions returning pointers to functions returning pointers to characters?
|
View Answer
|
|
What is the difference between char a[] = “string”; and char *p = “string”; ?
|
View Answer
|
|
What’s the auto keyword good for?
|
View Answer
|
|
What is the difference between char a[] = “string”; and char *p = “string”;?
|
View Answer
|
|
What can I safely assume about the initial values of variables which are not explicitly initialized?
|
View Answer
|
|
What does extern mean in a function declaration?
|
View Answer
|
|
What is an explicit constructor?
|
View Answer
|
|
What is a mutable member?
|
View Answer
|
|
When is a template a better solution than a base class?
|
View Answer
|
|
When should you use multiple inheritance?
|
View Answer
|
|
What is the difference between a copy constructor and an overloaded assignment operator?
|
View Answer
|
|
What is a conversion constructor?
|
View Answer
|
|
What is a default constructor?
|
View Answer
|
|
How does throwing and catching exceptions differ from using setjmp and longjmp?
|
View Answer
|
|
How many ways are there to initialize an int with a constant?
|
View Answer
|
|
What are the differences between a C++ struct and C++ class?
|
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 C++ Interview Questions & Answers - Exam Mode /
Learning Mode
|