Your IP : 216.73.216.40


Current Path : /var/www/html/bibhas.ghoshal/ITP_2019/lab/
Upload File :
Current File : /var/www/html/bibhas.ghoshal/ITP_2019/lab/prog6.c

#include <stdio.h>
int main(void)
{
	short short_x = 32767;			/*Signed--uses 15 bits*/
	int int_x=-65;				/*Signed--uses 31 bits*/
	unsigned long long_x=400000;		/*Unsigned--uses 32 bits*/

	printf("short_x: Decimal: %hd, Octal: %ho, Hex: %hx\n",short_x,short_x, short_x);
	printf("int_x: %d\n", int_x);
	printf("long_x = %lu\n", long_x);

	/* Data too large for type  --causes overflow*/
	short_x = short_x + 1;			/*16-bit value can't be held in 15 bits*/

	printf("short_x after incrementing: %hd\n", short_x);

	/*Wrong selection of format specifier*/
	printf("int_x printed with %%u = %u\n",int_x);
	int_x=123456;
	printf("int_x printed with %%d = %d, with %%hd= %hd\n",int_x, int_x);

	return 0;
}