Entrance Exams
Govt. Exams
Integer division truncates the decimal part. 5/2 = 2 (not 2.5) because both operands are integers.
Both syntaxes are correct. C allows initializing 2D arrays with or without explicit braces for each row.
sizeof(arr) gives total size of array. sizeof(arr[0]) gives size of one element. Dividing gives the number of elements: 20/4 = 5.
x++ returns 10 and increments x to 11. ++x increments x to 12 and returns 12. So y = 10 + 12 = 22. Wait, let me recalculate: y = 10 + 11 = 21 (as x becomes 11 after first post-increment, then ++x makes it 12).
All three functions can read strings, though gets() is deprecated due to security issues. fgets() is safer as it limits input size.
The #define directive replaces MAX with 10 during preprocessing. So x = 10 and output is 10. (Note: semicolon after MAX is not needed but doesn't affect the output)
The void pointer is a generic pointer that can hold addresses of any data type. void is also used for functions returning nothing and parameters.
p points to arr, so p[5] is equivalent to *(p+5) which gives the value at arr[5].
The left shift operator (<<) shifts bits to the left by 1 position, which is equivalent to multiplying by 2. So 5 << 1 = 10.
strlen() counts characters excluding the null terminator. "Hello" has 5 characters, so strlen(s) returns 5.