RSA Interview Question for Interns


Country: India




Comment hidden because of low score. Click to expand.
5
of 5 vote

its sizeof

- guest April 06, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

Your are write:

Sizeof: An operator and also a keyword.
#define: Pre-processor directive.
Printf: It is a function defined in stdio.h

- Anonymous April 19, 2012 | Flag
Comment hidden because of low score. Click to expand.
5
of 5 vote

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.

- spal April 06, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes
- spal April 06, 2012 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

printf is a library function
#define is a pre processor
so sizeof is a keywed

- ppriyaip916@gmail.com May 05, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
-1
of 1 vote

surely #define
sizeof maybe defined in stdlib.h
printf is defined in stdio.h

- Sysande April 05, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

'#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.

- spal April 06, 2012 | Flag
Comment hidden because of low score. Click to expand.
-1
of 1 vote

#define is keyword.

- Sam April 06, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
Comment hidden because of low score. Click to expand.
0
of 0 votes

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.

- spal April 06, 2012 | Flag


Add a Comment
Name:

Writing Code? Surround your code with {{{ and }}} to preserve whitespace.

Books

is a comprehensive book on getting a job at a top tech company, while focuses on dev interviews and does this for PMs.

Learn More

Videos

CareerCup's interview videos give you a real-life look at technical interviews. In these unscripted videos, watch how other candidates handle tough questions and how the interviewer thinks about their performance.

Learn More

Resume Review

Most engineers make critical mistakes on their resumes -- we can fix your resume with our custom resume review service. And, we use fellow engineers as our resume reviewers, so you can be sure that we "get" what you're saying.

Learn More

Mock Interviews

Our Mock Interviews will be conducted "in character" just like a real interview, and can focus on whatever topics you want. All our interviewers have worked for Microsoft, Google or Amazon, you know you'll get a true-to-life experience.

Learn More