long Modifier
The long modifier is used to declare variables with a larger size than the default int data type. It allows you to store integer values that require more memory than what int provides. The long modifier typically occupies 4 bytes of memory, allowing values from -2,147,483,648 to 2,147,483,647.
For example:
long bigNum = 1000000;
In this case, bigNum is a long integer variable initialized with the value 1,000,000. The long modifier is useful when dealing with large integer values that exceed the range of int.
Similar to short, the actual size of long may vary depending on the compiler & system architecture. However, it is guaranteed to be at least 4 bytes.
It's worth noting that you can also use the long long modifier to declare even larger integer variables, typically occupying 8 bytes of memory.
unsigned Modifier
The unsigned modifier is used to declare variables that can only hold non-negative values. By default, integer variables in C are signed, meaning they can store both positive & negative numbers. However, when you use the unsigned modifier, the variable can only represent positive values, including zero.
Let’s take an example of declaring an unsigned variable:
unsigned int count = 10;
In this case, count is an unsigned integer variable initialized with the value 10. The range of an unsigned variable depends on its size. For example, an unsigned int typically ranges from 0 to 4,294,967,295.
One common use case for unsigned modifiers is when working with bit manipulation or when you know that a variable will never hold negative values. By using unsigned, you can effectively double the positive range of the variable compared to its signed counterpart.
For example:
#include <stdio.h>
int main() {
int signedNum = -1;
unsigned int unsignedNum = -1;
printf("Signed: %d\n", signedNum);
printf("Unsigned: %u\n", unsignedNum);
return 0;
}

You can also try this code with Online C Compiler
Run Code
Output:
Signed: -1
Unsigned: 4294967295
In this code, we declare a signed int & an unsigned int, both initialized with the value -1. When we print their values, the signed variable correctly displays -1, while the unsigned variable interprets the binary representation of -1 as a large positive value.
signed Modifier
The signed modifier is used to explicitly declare variables that can hold both positive and negative values. In C, integer variables are signed by default, so using the signed modifier is often redundant. However, it can be used for clarity or to emphasize the intention of allowing negative values.
Let's take a look at an example of declaring a signed variable:
signed int temperature = -10;
In this case, temperature is a signed integer variable initialized with the value -10. The range of a signed variable depends on its size. For example, a signed int typically ranges from -2,147,483,648 to 2,147,483,647.
The signed modifier can be applied to char, short, int, and long data types. When applied to char, it indicates that the character variable can hold values from -128 to 127.
For example:
#include <stdio.h>
int main() {
signed char grade = 'A';
printf("Grade: %c\n", grade);
printf("ASCII value: %d\n", grade);
return 0;
}

You can also try this code with Online C Compiler
Run Code
Output:
Grade: A
ASCII value: 65
In this code, we declare a signed char variable grade and initialize it with the character 'A'. When we print the character and its ASCII value, we see that 'A' corresponds to the ASCII value 65.
Frequently Asked Questions
Can modifiers be combined in C?
Yes, modifiers can be combined, such as "unsigned long int" or "signed short int", to further specify the properties of variables.
Are modifiers necessary for all variable declarations?
No, modifiers are optional & used when you need to modify the default properties of a data type for specific requirements.
Do modifiers affect the range of values a variable can store?
Yes, modifiers like short, long, unsigned & signed directly impact the range of values a variable can represent based on the memory allocated.
Conclusion
In this article, we discussed the concept of modifiers in C programming. We learned about short, long, unsigned, and signed modifiers and how they allow programmers to modify the properties of data types. With modifiers, you can optimize memory usage, specify variable ranges, and ensure your variables align with your program's requirements. Modifiers provide flexibility and control over data types.
You can also check out our other blogs on Code360.