C questions in placement tests and university exams are rarely about syntax alone. Most of what you will find here is output prediction, pointer arithmetic, arrays and strings, structures and unions, storage classes, recursion, and file handling. The explanations walk through memory behaviour step by step, which is usually where the confusion sits rather than in the code itself.
Which of the following correctly declares and initializes a 2D array?
Answer: C
Both syntax forms are valid in C. Elements can be provided in nested braces or as a linear list, and they fill row by row.
Q.202Medium
What is the relationship between array name and pointer in C?
Answer: A
Array names decay to pointers to the first element in expressions, but they are not truly pointer variables. The array name cannot be reassigned.
Q.203Medium
If str = "Hello", what is the value of str[5]?
Answer: A
"Hello" has 5 characters, so valid indices are 0-4. Index 5 contains the null terminator '\0' that marks the end of the string.
Q.204Medium
In a 2D array int matrix[4][5], which statement about memory layout is true?
Answer: A
C uses row-major order for 2D arrays. matrix[0][0], matrix[0][1]...matrix[0][4], matrix[1][0]... are stored sequentially in memory.
Q.205Medium
What is the output of sizeof(arr)/sizeof(arr[0]) when arr is declared as int arr[10]?
Answer: A
This expression calculates array length. sizeof(arr) gives total bytes (40 on 32-bit system), sizeof(arr[0]) gives bytes per element (4), so 440=10.
Q.206Medium
Which string function modifies the original string in-place?
Answer: D
Both strtok() (modifies by replacing delimiters with '\0') and strcpy() (copies and overwrites destination) modify strings in-place.
Q.207Medium
What happens when you try to modify a string literal in C?
Answer: C
String literals are stored in read-only memory. Attempting modification causes undefined behavior (often segmentation fault). This is why char *str = "text"; str[0]='T'; is dangerous.
Q.208Medium
What is the time complexity of inserting an element at the beginning of an unsorted array?
Answer: B
Inserting at the beginning requires shifting all n elements one position right, making it O(n). Insertion at the end is O(1) if space exists.
Q.209Medium
Which function is used to find the first occurrence of a character in a string?
Answer: B
strchr() finds the first occurrence of a character. strrchr() finds the last occurrence. strstr() finds substrings.
Q.210Medium
What will be the output? char arr[] = "ABC"; printf("%d", sizeof(arr));
Answer: B
sizeof includes the null terminator. "ABC" has 4 bytes (A, B, C, \0).
Q.211Medium
Consider the code: int *p; int arr[5] = {10, 20, 30, 40, 50}; p = arr; What is *(p+2)?
Answer: B
p points to arr[0]. p+2 points to arr[2], which contains 30.
Q.212Medium
Which of the following will correctly compare two strings?
Answer: B
A compares pointers, not string content. strcmp() compares actual string values character by character.
Q.213Medium
What is the correct syntax to concatenate two strings safely in modern C?
Answer: D
strcat() is unsafe due to buffer overflow risk. strncat() and sprintf() provide bounds checking.
Q.214Medium
What does the following code do? char str[] = "HELLO"; for(int i = 0; str[i]; i++) str[i] = str[i] + 32;
Answer: A
Adding 32 to uppercase ASCII values converts them to lowercase (A=65, a=97, difference=32).
Q.215Medium
Consider: char str[10]; strcpy(str, "Hello"); What is the state of memory after this?
Answer: C
strcpy copies "Hello" and adds null terminator at position 5. Positions 6-9 remain uninitialized.
Q.216Medium
What does strtok(str, delim) return on each call until the string ends?
Answer: B
strtok() returns a pointer to the next token separated by the delimiter. Returns NULL when no more tokens exist.
Q.217Medium
What is the correct way to declare a pointer to a character array?
Answer: B
char (*ptr)[] declares ptr as a pointer to a character array. The parentheses are crucial for correct precedence.
Q.218Medium
What happens when you try to modify a string literal in C? char *str = "Hello"; str[0] = 'J';
Answer: B
String literals are stored in read-only memory. Attempting to modify them causes undefined behavior or segmentation fault.
Q.219Medium
Which of the following correctly reverses a string in-place?
Answer: A
strrev() is a non-standard but commonly used function (available in string.h in some compilers) that reverses a string in-place.
Q.220Medium
What is the output of the following code? char str[] = "GATE"; printf("%d", sizeof(str));
Answer: B
sizeof(str) returns 5 because the array includes 4 characters plus 1 null terminator.