Amazon Interview Question for Software Engineer / Developers






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

stackoverflow.com/questions/190232/can-a-recursive-function-be-inline

- GekkoGordan February 08, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

macro function: code is replaced for sure during preprocessing.
inline function: code may be or may not be replaced depending on the size of the function and other factors which depends on the compiler.

if we define all functions as inline, the executable size will be huge.

- yours.ramesh February 08, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

macro function, code is replaced, but it is just done one pass of the input file. so, only first occurence is replaced. correct me If I am wrong.

If inline function is recursive,

- Messi February 09, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Only problem here is with semicolon, which can nullify potentially coming else type of statements:
gcc.gnu.org/onlinedocs/cpp/Swallowing-the-Semicolon.html#Swallowing-the-Semicolon

- vt February 09, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

1. There is no such thing like recursive macro ( according to c++ standards)
2. Recursive inline functions are valid. But depends on how the compiler handle/optimize them. The compiler will either recurse for a certain depth and then consider them as normal functions. Or if the function recursion is HUGE, then the compiler might treat them as normal functions.

Please correct me if I am wrong.

- crackit February 12, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

1. There is no such thing like recursive macro ( according to c++ standards)
2. Recursive inline functions are valid. But depends on how the compiler handle/optimize them. The compiler will either recurse for a certain depth and then consider them as normal functions. Or if the function recursion is HUGE, then the compiler might treat them as normal functions.

Please correct me if I am wrong.

- crackit February 12, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

there is no recursive macro

below code throws an error"SUM object not found"

#define SUM(x) do{\
				cout<<SUM(x)<<endl;\
				}while(0)

- siva.sai.2020 March 08, 2014 | Flag Reply


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