Printf('The value of signed variable is: %u\n',a) Let us see the C program that converts the signed variable to an unsigned variable: In C, the compiler performs implicit casting but sometimes it gives a warning so most of the time they are manually cast explicitly which is done using the data type you want to convert it in the parenthesis to another data type. Let us see if the variable is declared signed int and we want it to convert it into unsigned int which is a bit confusing in C programming. Printf('Unsigned int values range: %u\n', (unsigned int) UINT_MAX) Įxplanation: So in general, in C we have signed and unsigned integer data types to declare in the program. Let us see a small C program that uses unsigned int: The format specifier used for an unsigned int data type in C is “ %u ”. The unsigned int can contain storage size either 2 or 4 bytes where values ranging from or. We know that the data type “int” has the size of 4 bytes where it can hold values from -2 31 to 2 31 – 1, but in this, we have declared “x” as unsigned int so it can hold values from 0 to 2 32 – 1. Web development, programming languages, Software testing & othersĮxplanation: In the above example, the variable “a” can hold the values only zero and positive values. Start Your Free Software Development Course