RSA Interview Question
InternsCountry: India
There is exactly one keyword in the given options. See the Wikipedia article on "C Syntax" and search for "keywords" for a list of keywords in C. sizeof is the only keyword in the list.
So the second answer by 'guest' is the only correct answer.
'#define' is not a keyword because it is not even parsed by the "compiler" (lexer more specifically), strictly speaking. '#define' is parsed by the preprocessor. It's a preprocessor directive. It is true that 'sizeof' is an operator but nothing in the C standard prevents an operator for being a keyword. Keywords are simply reserved words recognized by the lexer of the compiler. They may or may not be an operator or other language units.
'sizeof' is not defined in any header because it is not a function. It is a keyword and thus built into the lexer part of the compiler. In fact, 'sizeof' doesn't always require parentheses. For example;
sizeof a
is a valid way of using the 'sizeof' operator if 'a' is a variable.
'#define' is not a keyword because it is not even parsed by the "compiler" (lexer more specifically), strictly speaking. '#define' is parsed by the preprocessor. It's a preprocessor directive.
'sizeof' is not defined in any header because it is not a function. It is a keyword and thus built into the lexer part of the compiler. In fact, 'sizeof' doesn't always require parentheses. For example;
sizeof a
is a valid way of using the 'sizeof' operator if 'a' is a variable.
its sizeof
- guest April 06, 2012