Qualcomm Interview Question for Software Engineer / Developers






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

basically if temp is not defined as volatile, the compiler will optimize the code as
while(temp--).

- newlifeseattle December 31, 2009 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

You are right !

- DesiGrad March 25, 2010 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

temp is not initialized to any value and its basically an infinite loop

the compiler can optimize it as

while(1)

this doesnt require fiddling with temp variable

- Anonymous May 07, 2010 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

@Anonymous Uninitialized does not mean this is infinite loop - the initial value is just indeterministic => can be any value => when sufficient iterations done, it can go to 0 theoretically and break the loop.

- Dilbert Einstein June 19, 2012 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

when we use the volatile keyword...then compiler will not optimize the code...
http://en.wikipedia.org/wiki/Volatile_variable

- gnu October 21, 2009 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

So, there will be no change in behavior of the compiler since value of temp is changing within the loop and it will force the program to read the value of the variable everytime.

- Anonymous October 23, 2009 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

@ newlifeseattle

but in the above code..the compiler will not optimize the code even if the variable is a local variable bcoz the temp value changes each and every time...

- JackMaster January 03, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

can you please explain why the compiler wont optimize if the value of temp changes each and every time...Thanks

- Anonymous January 16, 2010 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

u r rite jackmaster ... no diff. in dis case ...

- coolpyro February 14, 2010 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

Since the 'temp' value is not at all 'used', this loop is a
IDLE loop(doing nothing) and compiler will goahead and remove the whole loop right?

- Pawan May 15, 2010 | 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