#include<stdio.h>
#include<conio.h>
main()
{
unsigned int u=65537;
printf("\nu=%u",u);
getch();
}
/*The range of unsigned integer is 0 to 65535.If goes beyond its limit the compiler would not flag
any error message*/
The above program demonstrates the concept of “Wrapping Around” in C programming. The program declares an unsigned integer variable ‘u’ and assigns it the value of 65537. As the range of unsigned integer is from 0 to 65535, when the value of ‘u’ exceeds this range, it wraps around to the minimum value that can be stored in an unsigned integer (0) and starts counting from there.
In this case, instead of giving an error or producing an unexpected result, the value stored in ‘u’ becomes 1 (65537 – 65536). This is known as wrapping around.
The program then uses the printf statement to print the value of ‘u’ which is 1.
It’s important to note that wrapping around can cause unexpected results and it is important to check for overflow when working with unsigned variables.
Thanks