Govt Exams
Size of long double varies: typically 12 or 16 bytes on different systems and compilers.
Both 'int x;' and 'static int x;' allocate memory. Extern only declares without allocation.
int x = 10;
int *p = &x;
printf("%d", *p + 5);
*p dereferences pointer to get value 10, then 10+5=15 is printed.
Static variables retain their values between function calls and are initialized only once, maintaining state across invocations.
%ld is for long int, %lld is for long long int, and %d is for regular int. Using wrong specifier can cause undefined behavior.
Uninitialized local variables contain garbage values (random data from memory). Static/global variables are initialized to 0 by default.
When assigning a double to int, C performs implicit type conversion with truncation (not rounding). The decimal part is discarded.
char (signed) has range -128 to 127, while unsigned char has 0 to 255. The latter can represent extended ASCII characters (128-255).
sizeof(int) is typically 4 bytes and sizeof(char) is 1 byte, giving 5 on most systems. However, sizes are implementation-dependent (at least int=2, char=1).
C allows implicit type conversion. When assigning larger to smaller type, truncation or data loss may occur without any compiler error.