In C, when you declare an array like int arr[10], what does the array name 'arr' represent?
Answer: A
Array names decay to pointers to their first element in most contexts. 'arr' is equivalent to &arr[0] and cannot be reassigned.
Q.142Easy
What is the size of the string 'Hello' when stored in a character array with null terminator?
Answer: B
'Hello' has 5 characters plus 1 null terminator (\0), making total 6 bytes.
Q.143Easy
Which of the following correctly initializes a 2D array of integers?
Answer: A
Option A is valid - 2D arrays can be initialized with all elements in a single brace. Options B and C are invalid as at least one dimension must be specified.
Q.144Easy
In the declaration char *str[5], what does the array represent?
Answer: A
The syntax char *str[5] declares an array of 5 pointers, each pointing to a character (or string). The brackets bind tighter than asterisk.
Q.145Easy
How many elements can be stored in a 2D array declared as int matrix[4][5]?
Answer: D
A 2D array with dimensions [4][5] contains 4 × 5 = 20 elements total.
Advertisement
Q.146Easy
What is the correct way to declare and initialize a string in C?
Answer: B
Option B shows two valid ways: pointer to string literal or character array. Option A is wrong (single char), C is wrong (no String type in C).
Q.147Easy
What is the output of: int arr[] = {10, 20, 30}; printf("%d", *(arr+1));?
Answer: B
arr+1 points to second element (arr[1]). Dereferencing gives value 20.
Q.148Easy
What will be the size in bytes of int arr[5] on a 32-bit system?
Answer: C
On 32-bit systems, int is typically 4 bytes. 5 elements × 4 bytes = 20 bytes total.
Q.149Easy
Consider the following code:
char str[] = "HELLO";
int len = 0;
while(str[len] != '\0') {
len++;
}
printf("%d", len);
What will be the output?
Answer: A
The string "HELLO" has 5 characters. The while loop counts characters until it encounters the null terminator '\0'. The output will be 5. The null terminator is not counted in the length.
Q.150Easy
Which operator is used to get the address of a variable in C?
Answer: B
The & operator (address-of operator) returns the memory address of a variable.
Q.151Easy
What will be the size of a pointer variable on a 64-bit system?
Answer: C
On a 64-bit system, a pointer is 8 bytes (64 bits) regardless of the data type it points to.
Q.152Easy
What is a NULL pointer?
Answer: A
A NULL pointer is a pointer that points to memory address 0, indicating it doesn't point to any valid memory location.
Q.153Easy
Which of the following is NOT a valid pointer declaration?
Answer: D
& is a reference operator used in C++, not in C. In C, pointers are declared using *.
Q.154Easy
Identify the output:
char *str = "Hello";
printf("%c", *str);
Answer: A
*str dereferences the pointer to get the first character of the string, which is 'H'.
Q.155Easy
A pointer variable stores the _____ of another variable.
Answer: B
Pointers store memory addresses of variables. The address-of operator (&) retrieves this address.
Q.156Easy
What is the size of a pointer variable on a 32-bit system?
Answer: B
On a 32-bit system, all pointers are 4 bytes (32 bits) regardless of the data type they point to.
Q.157Easy
Consider: int x = 10; int *p = &x; What does the expression *p represent?
Answer: C
The dereference operator (*) accesses the value at the address pointed to by p, which is the value 10.
Q.158Easy
Which operator is used to get the address of a variable?
Answer: B
The & (address-of) operator returns the memory address of a variable.
Q.159Easy
What will be printed by the code: char *ptr = "Hello"; printf("%c", *ptr);
Answer: A
ptr points to the first character of the string, so *ptr dereferences to 'H'. The %c format specifier prints a single character.
Q.160Easy
What is the size of a pointer variable in a 64-bit system?
Answer: A
In a 64-bit system, all pointers occupy 8 bytes regardless of the data type they point to.