Microsoft Interview Question for Software Engineer in Tests






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

My Answer is that in this do-while loop will go in indefinite loop as value of 'i' is not getting increment in case when 'a' or 'A' is encountered.. you guys can you figure out some other bugs ???

- ajitpec January 29, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

tmpvar is of type int while len is unsigned long. If parameter > 2^31 is passed it will be a problem.

Also tmpvar is unnecessary.

- Rayden January 29, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

The check of *pch==NULL etc is wrong. The correct check would be if pch==NULL

- Anonymous January 29, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

1)
if(pch[i]=='A' || pch[i]=='a')
ret++
else
/* there should not be this else, because we have increase the index anyhow to check the next character*/
i++

2) also tmpvar is int and len in unsigned long.. might cause problem

- sunny January 30, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

@Sunny Where we have increased the index that is the problem ret++ is count of 'A' or 'a' not index

- ajitpec January 30, 2011 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

Also in the line
f(*pch==NULL || !strcmp(pch," "))

the "!" should not be there for the strcmp() check because, we should return 0 if pch is an empty space.

- j February 01, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

! is required as strcmp returns 0 if input parameter are equal.

- G March 22, 2011 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

Guys I see one more bug

if(*pch==NULL || !strcmp(pch," "))
would return true if there is a sapce found in the input string and program will terminate.
Thus this program would not work for multi-word string.

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

it accept a string, but the pointer pch pointed to char.
if(*pch==NULL || !strcmp(pch," ")) instead of take off the first*, I think should add the second*...
It should be if(*pch==NULL || strcmp(*pch," "))

- yangjian0219 March 20, 2011 | 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