C codes on Integer types

Previous
Next

Note: When we don’t specify the variable is either signed or unsigned, by default it is signed type.

#include<stdio.h>
int main()
{
	short s = 32769;
	printf("s val : %d \n", s);	
	return 0;	
}
This image has an empty alt attribute; its file name is c_short_code1.png
#include<stdio.h>
int main()
{
	short s = -32744;
	printf("s val : %d \n", s);	
	return 0;	
}
This image has an empty alt attribute; its file name is c_short_code2.png
#include<stdio.h>
int main()
{
	unsigned short s = -5;
	printf("s val : %u \n", s);	
	return 0;	
}
This image has an empty alt attribute; its file name is c_short_code3.png
#include <stdio.h>
#include <limits.h>
int main()
{
	printf("Unsigned short max : %d \n", USHRT_MAX);
	return 0;
}

Output:
Unsigned short max : -1
This image has an empty alt attribute; its file name is c_short_code4.png
Previous
Next

Add Comment

Courses Enquiry Form