What is the function of unsigned in C++?

In C++, unsigned is a data type modifier used to declare unsigned integer types. The unsigned keyword can be applied to integer types such as char, short, int, and long to indicate that these types can only store non-negative values (i.e. integer values greater than or equal to 0) and do not have a negative sign.

Variables of unsigned type can store larger positive integer values than the same-sized signed integer types because they do not need to store a sign bit. Unsigned variables are typically used in situations where there is a need to store large positive integer values or ensure that the result is positive in arithmetic operations.

In general, the purpose of “unsigned” in C++ is to declare an unsigned integer type, used to store non-negative integer values, and can store larger positive integer values than the same size signed integer type.

Leave a Reply 0

Your email address will not be published. Required fields are marked *