C++ Programming Question: Download C++ Programming PDF

How do you decide which integer type to use?

Tweet Share WhatsApp

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.

Download C++ Programming PDF Read All 120 C++ Programming Questions
Previous QuestionNext Question
Anything wrong with this code?
T *p = 0;
delete p;
What is the best way to declare and define global variables?