Continental Interview Question for Software Engineer / Developers


Country: India
Interview Type: In-Person




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

You're definitely correct that in C or C++ code, the optimization will be done at compile time if it is done at all. In your particular situation, the compiler definitely could decide to perform the optimization.

- eugene.yarovoi February 04, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
1
of 1 vote

Optimizations can never be done during run time.

- Anony February 04, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

Not in C, that is.

- eugene.yarovoi February 04, 2012 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

The optimization should happen during compile time, with respect to the above chunk of code.
This is because
1) Other than " abc = 3 " the code is not being altered anywhere
2) Also you don't see any statement like " abc = RHS " where you are trying to assign a new value at run time.

Hece the compiler is very sure that " Else " part never gets executed. Hence code optimization should happen @ compile time.

- Vijay Rajanna February 06, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

It says 'abc' is a global variable, which could be externed in other file and modified over there??
so i don't think compiler can optimize this particular case..

plz correct if wrong..

- Anurag February 24, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

It says 'abc' is a global variable, which could be externed in other file and modified over there??
so i don't think compiler can optimize this particular case..

plz correct if wrong..

- Anurag February 24, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

correct. In this case compiler is not sure if the variable is mopdified in any other translation unit.

- Ananta March 10, 2012 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

Oh...I interpreted all this code to be part of a method, with abc being a local variable.

- eugene.yarovoi June 19, 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