What happens when you declare a variable without initializing it?
Auto variables (local variables) contain unpredictable garbage values if not initialized. Static/global variables are initialized to 0.
Which of the following correctly demonstrates pointer arithmetic?
Option A shows pointer arithmetic where p++ increments the pointer by the size of int (4 bytes). Other options are regular arithmetic operations.
What is the output of the following code?
int a = 5;
int *p = &a;
int q = &p;
printf("%d", q);
q is a pointer to pointer p. **q dereferences both pointers, giving the value of a, which is 5.
Which data type is most suitable for storing a decimal number with high precision?
long double provides maximum precision (typically 80-128 bits) for decimal numbers compared to float (32 bits) and double (64 bits).
What is the range of values for a signed char in C?
A signed char occupies 1 byte (8 bits). With sign bit, it ranges from -128 to 127 (2^7 to 2^7-1).
Advertisement
Which keyword is used to modify a variable so that it cannot be changed?
The const keyword makes a variable read-only after initialization. Its value cannot be modified during program execution.
In C, which storage class has the longest scope and lifetime?
extern variables have global scope and exist throughout program execution. They can be accessed across multiple files.
What is the size of the double data type in most 64-bit systems?
In standard C on 64-bit systems, double occupies 8 bytes and can store values with approximately 15-17 significant digits.
Which of the following variable names is INVALID in C?
Variable names cannot start with a digit in C. Valid names must begin with a letter (a-z, A-Z) or underscore (_).
What will be the result of sizeof(int) on a typical 32-bit system?
On 32-bit systems, int is typically 4 bytes (32 bits). However, the exact size is implementation-defined per C standard.
Which storage class variable is automatically initialized to 0 if not explicitly initialized?
static variables are automatically initialized to 0 for numeric types and NULL for pointers if not explicitly initialized.
Consider: long long int x; What is the minimum guaranteed size of x according to C standard?
According to C99 standard, long long int is guaranteed to be at least 8 bytes (64 bits).
Which of the following demonstrates proper type casting in C?
C uses C-style casting with parentheses: (type) expression. This converts 5.7 to integer 5.
What is the difference between 'signed' and 'unsigned' char in terms of range?
Signed char uses 1 bit for sign, giving -128 to 127. Unsigned char uses all 8 bits for magnitude, giving 0 to 255.
Which keyword prevents a local variable from being optimized by compiler into a register?
volatile tells compiler that a variable's value may change unexpectedly and should not be optimized. It's often used for hardware registers.
In the declaration 'int *p, q;', what are the data types of p and q?
The * applies only to p. So p is int*, and q is int. To declare both as pointers: int *p, *q;
What happens when you attempt to store a double value in an int variable without explicit casting?
Implicit conversion truncates the fractional part. Modern compilers may warn but allow this. Example: int x = 5.9; results in x = 5.
Which of the following is a correct way to declare a constant variable in modern C?
Option B is the correct C99/C11 syntax. #define is preprocessing, while const is a type qualifier that provides type safety.
What is the output of: printf("%d", sizeof(char) + sizeof(int) + sizeof(float)); on a typical 32-bit system?
sizeof(char)=1, sizeof(int)=4, sizeof(float)=4 on 32-bit systems. Total: 1+4+4=9 bytes.
A variable declared with 'register' storage class suggests to the compiler to store it in:
register is a hint to compiler to store variable in CPU register for faster access. Compiler may ignore this if registers unavailable.