Microsoft Interview Question for Software Engineer / Developers






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

int implementAtoI(const string channelNum)
{
int b = 0;
for (int i = 0; i < channelNum.size(); i++)
{
if((int)(channelNum[i])>47 && (int)(channelNum[i]< 58))
{
do
{
int a = 0;
a = (int)channelNum[i]-48;
b = b*10 + a;
i++;
}while (i <= channelNum.size() && (channelNum[i] > 47 && channelNum[i] < 58));

return b;
}
else
break;
}

cout << endl << endl << "reutrning zero " << endl << endl;
return 0;
}

- Pratik April 04, 2006 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Have that!

int myshiteatoi(char *x)
{
int final = 0;

while(true)
{
if(*x >= '0' && *x <= '9')
{
final *= 10;
final += *x - '0';
x++;
}
else
break;
}

return final;
}

- Nutty April 05, 2006 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Sorry incomplete code :)
long atoi(const char* str){
const char* p = str;
int sign;

// fail if str is null or length is 0

// get sign if the first char is sign char

// while loop handle each following char
// 1. cut string after incorrect char
// 2. handle overflow case

// return num*sign;

- James May 10, 2006 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Have to consider special cases
1. parameter may be NULL
2. there might be + or - sign in the beginning of the string
3. each char should be between '0' and '9'
4. may need to use linked list for int overflow
5. parameter char may not have NULL character in it

and what else?

- joker September 28, 2006 | 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