Govt. Exams
Entrance Exams
#include
int main() {
char str[] = "GATE";
printf("%d", sizeof(str));
return 0;
}
sizeof(str) includes the null terminator. The string "GATE" has 4 characters plus 1 null terminator = 5 bytes.
2D array syntax is int arr[rows][columns]. So int arr[3][4] creates 3 rows and 4 columns.
\t is the escape sequence for horizontal tab. \n is newline, \h and \s are not valid escape sequences.
'long long' is guaranteed to be at least 64 bits (8 bytes) as per C99 standard.
x++ is post-increment. The current value (10) is printed first, then x is incremented to 11. So output is 10.
Integer division truncates the result. 5/2 = 2 (not 2.5) because both operands are integers.
The correct syntax is 'int *ptr;' where * indicates ptr is a pointer to int.
malloc() and other dynamic memory allocation functions are declared in <stdlib.h>.
%c format specifier prints the character representation of ASCII value 65, which is 'A'.
By C standard, sizeof(char) is always 1 byte, regardless of platform.