My experience Microsoft conducted on 22nd December, 2010.
First round was a written test of an hour. There were 6 questions (4 programming and 2 test cases) 10 marks each.
1) Find output of following code?
void main()
{
void *ptr;
char *a=,A,;
char *b="TAN";
int i=50;
ptr=a;
ptr=(*char)malloc(sizeof(a));
printf("%c",*ptr);
ptr=i;
ptr=(*int)malloc(sizeof(i));
printf("%d",++(*ptr));
ptr=b;
ptr=(*char)malloc(sizeof(b));
printf("%c",++(*ptr));
}
Ans: A51AN
2) Write a program that takes a no. from user and prints the no. subtracting 5 each time from the no. till the no. doesnt crosses/reaches 0.And again prints the nos. Now increasing 5 each time till the no. doesnt reaches/crosses original no. Don,t use any loops or goto stmnt. And don,t declare any local variables.
Ans: use recursion.
3) Convert a no. from string to integer.
Eg: str:"1234"
convert to int a=1234;
Ans: while(*ptr!=NULL)
{
a=(a*10)+(*ptr-48);
}
4) Find the subarray of an array that has the greatest sum? Array contains both +ve as well as -ve nos.
Ans: I did it using 3 loops but when I went for the 2nd technical round the interviewer told me a very simple and optimal program for the same.
sumtillnow=0;
sum=0;
for(i=0;i< p="">
{
sumtillnow+=a[i];
if(sumtillnow>sum)
sum=sumtillnow;
if(sumtillnow