In C, which storage class has the longest scope and lifetime?
A auto B register C static D extern
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?
A 4 bytes B 8 bytes C 16 bytes D Compiler dependent, no fixed size
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?
A _myVar B myVar123 C 123myVar D my_Var
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?
A 2 bytes B 4 bytes C 8 bytes D Undefined
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?
A auto B register C static D extern
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?
A 4 bytes B 8 bytes C 16 bytes D Compiler defined
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?
A (int) 5.7 B int(5.7) C int <- 5.7 D 5.7 as int
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?
A No difference B signed: -128 to 127, unsigned: 0 to 255 C signed: 0 to 127, unsigned: -128 to 255 D signed: 0 to 256, unsigned: -128 to 128
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?
A volatile B static C const D restrict
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?
A Both are pointers to int B p is pointer to int, q is int C Both are int D p is int, q is pointer to int
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?
A Compilation error B Runtime error C The fractional part is silently truncated D The value is rounded
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?
A #define PI 3.14 B const float PI = 3.14; C PI = 3.14 (const); D constant float PI = 3.14;
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?
A 4 B 9 C 12 D 13
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:
A Main memory B CPU registers C Hard disk D Cache memory
register is a hint to compiler to store variable in CPU register for faster access. Compiler may ignore this if registers unavailable.
What is true about the variable declared as 'extern int count;' inside a function?
A It declares a new local variable B It refers to a global variable defined elsewhere C It creates a static variable D It's a compilation error
extern is a declaration (not definition) that tells compiler the variable exists elsewhere in program. It provides global scope.
Consider a structure with int (4 bytes), char (1 byte), and double (8 bytes). What is the minimum size due to alignment requirements?
A 13 bytes B 16 bytes C 24 bytes D 20 bytes
Due to structure padding/alignment, the size becomes 24 bytes (8-byte alignment for double). Members are padded to maintain alignment.
Which of the following statements about type qualifiers is INCORRECT?
A const prevents modification after initialization B volatile prevents compiler optimization C restrict allows pointer aliasing D restrict is a C99 feature
restrict prevents pointer aliasing (not allows). It tells compiler that pointer is the only way to access that object.
What is the default data type of a floating-point constant in C?
A float B double C long double D It depends on the compiler
In C, floating-point constants like 3.14 are treated as double by default. To specify float, you need to use 3.14f suffix.
What is the size of int data type on a 32-bit system according to C standard?
A 2 bytes B 4 bytes C At least 2 bytes (implementation-dependent) D 8 bytes
The C standard guarantees int is at least 2 bytes, but most 32-bit systems use 4 bytes. The exact size is implementation-dependent.
In the declaration 'int arr[10], *ptr;', which statement is correct?
A ptr is an array pointer, arr is an integer pointer B ptr is a pointer to int, arr is an array of 10 integers C Both arr and ptr are integer pointers D arr is a pointer, ptr is an array
The declaration uses comma separation. 'int arr[10]' declares an array of 10 integers, while '*ptr' declares a pointer to int.