Modifiers in C++

TCS NQT Registration Steps Large
Registrations Starts on 7th June, 2019
Registration Ends on 10th July, 2019
Hall Ticket 15th July, 2019
Online Test 20th July, 2019
Interview Starts on 25th July, 2019

TCS NQT Registration Steps 2020

TCS NQT Registration for 2020 Batch is explained on this page, make sure that you follow all, each and every step mentioned on this page. As last time for 2019 Batch 10% students who filled the form incorrectly didn’t get their hall tickets. So make sure that you follow each step mentioned on this age. 

Modifiers in C++

Modifiers in C++ are extensions to existing data types and can change the storing capacity and behaviour of the data types and variables. These modifiers precede the data types like int, char, float etc.

Modifiers in C++

Some modifiers are –

  • long
  • signed
  • unsigned
  • short

Modifiers Details

These modifiers also modify the range and size of of the data types that they are preceding. The below list gives you an idea on the same –

Data TypeSizeRange
bool1 byteTrue/False
char1 byte-128 to 127 or 0 to 255
signed char1 byte-128 to 127
unsigned char1 byte0 to 255
int4 bytes-2147483648 to 2147483647
signed int4 bytes-2147483648 to 2147483647
unsigned int4 bytes0 to 4294967295
short int2 bytes-32,768 to 32,767
signed short int2 bytes-32,768 to 32,767
unsigned short int2 bytes0 to 65,535
long int4 bytes-2,147,483,648 to 2,147,483,647
signed long int4 bytes-2,147,483,648 to 2,147,483,647
unsigned long int4 bytes0 to 4,294,967,295
float4 bytes1.17549e-38 to 3.40282e+38
Double Floating Point8 bytes2.22507e-308 to 1.79769e+308
No ValueNot validNot valid
Wide character2 or 41 wide character

The sizes of the variables might be different for various compilers, what we have given are general sizes that are useful for various competitive examinations.

  • int – can be preceded with long, signed, unsigned, short
  • char – can be preceded with signed and unsigned

The following code will print the sizes of various data types and their modifiers –

using namespace std;

int main() {
   cout << "Size of char : " << sizeof(char) << endl;
   cout << "Size of int : " << sizeof(int) << endl;
   cout << "Size of short int : " << sizeof(short int) << endl;
   cout << "Size of long int : " << sizeof(long int) << endl;
   cout << "Size of long int : " << sizeof(unsigned long int) << endl; 
<< "Size of float : " << sizeof(float) << endl; cout << "Size of double : " << sizeof(double) << endl; cout << "Size of wchar_t : " << sizeof(wchar_t) << endl; return 0; }

The following will be the output of the code –

Size of char : 1
Size of int : 4
Size of short int : 2
Size of long int : 8
Size of long int : 8
Size of float : 4
Size of double : 8
Size of wchar_t : 4

If you use just the modifier followed by the variable, in C++ the assignment is understood for int, for unsigned, short or long

For example writing the following means the same thing and it implies that the variable is an unsigned int type.

unsigned x;
unsigned int y;

Type Qualifiers

Read more about type qualifiers here on this page.