Govt. Exams
Entrance Exams
extern variables have global scope and exist throughout program execution. They can be accessed across multiple files.
long double provides maximum precision (typically 80-128 bits) for decimal numbers compared to float (32 bits) and double (64 bits).
Auto variables (local variables) contain unpredictable garbage values if not initialized. Static/global variables are initialized to 0.
float x = 5 / 2;
printf("%f", x);
5/2 performs integer division (both operands are int), resulting in 2. This is then converted to float as 2.0.
Static variables are automatically initialized to 0 by the compiler.
int x = 10;
int *p = &x;
printf("%d", *p);
p is a pointer to x. *p dereferences the pointer, giving the value of x, which is 10.
static restricts variable visibility to the current file; extern declares a variable defined elsewhere with global scope.
Unsigned int uses all 32 bits for magnitude, giving range 0 to 2^32 - 1 (0 to 4,294,967,295).
In a 64-bit system, long double typically occupies 16 bytes (128 bits), which is the maximum among these options.
int x = 5;
float y = x;
printf("%f", y);
Implicit type conversion occurs from int to float. The value 5 is converted to 5.0 and printed as 5.000000 with %f format specifier.