signed Modifier
Signed variables can store positive, negative integers, and zero.
Example:
signed int a = 45;
signed int b = -67;
signed int c = 0;
Here,
- ‘a’ is a positive valued integer.
- ‘b’ is a negative valued integer.
- ‘c’ is a zero-valued integer.
Example:
C++
// C++ program to demonstrate // the signed modifier #include <iostream> using namespace std; // Driver Code int main() { cout << "Size of signed int : " << sizeof ( signed int ) << " bytes" << endl; cout << "Size of signed char : " << sizeof ( signed char ) << " bytes" << endl; return 0; } |
Size of signed int : 4 bytes Size of signed char : 1 bytes
Note: The int datatype is signed by default. So, int can be directly be used instead of signed int.
C++ Type Modifiers
Modifiers are used in C++ to change or give extra meaning to already existing data types. It’s added to primitive data types as a prefix to change their meaning. A modifier is used to change the meaning of a basic type so that it better matches the requirements of different circumstances.
Following are the C++ data type modifiers:
- signed
- unsigned
- short
- long
These modifiers can be used with the following Built-in Data Types.