Professional Documents
Culture Documents
29-sep-2014
It was an awesome experience.
I had gone through nearly 8 rounds
1.short code round (20-30 mins)
a.accept a week day like wednesday and a number like 2 then display sum as frida
y and subtraction as monday
b. display all odd numbers whose sum of digits is 7
2.logical round(1.15mins)
it is all about flow chart which u can get in net first two problems may change
3.pair programming round(1.30 mins)
a thoughtworker will be guiding u on the problem
problem statement
down vote favorite
An airlines company has several planes of the same type.Each plane has a seating
capacity of 24 X 3 rows and 8 seats in each row split has shown.
1 [a] [b] [c] [d] [e] [f] [g] [h]
2 [a] [b] [c] [d] [e] [f] [g] [h]
3 [a] [b] [c] [d] [e] [f] [g] [h]
If 4 people book-allocate 4 seats in middle row.Else 2 on the right and 2 on
the left.
if 3 people book- id middle section is empty,allocate there continuously.Els
e go to next row middle section.
if 2 people book-allocate the edge seats.
if 1 person has booked -then allocate whatever free seat available.
eginput 4
output-1c 1d 1e 1f
input-3
output- 2c 2d 2e
input-2
output-1a 1b
4.technical 1(1hr)
which is your favourite subject and practical questions on it,real world impleme
ntation,
how u could map ur knowledge to application level.no definitions only class diag
ram ,piece of code
what is dangling pointer ?
what is inheritance?implementation...
polymorphism ,function overloading,operator overloading
data abstraction,data hiding
how c++ different from c
reverse(word_begin, temp-1);
word_begin = temp+1;
}
} /* End of while */
/*STEP 2 of the above algorithm */
reverse(s, temp-1);
}
/* UTILITY FUNCTIONS */
/*Function to reverse any sequence starting with pointer
begin and ending with pointer end */
void reverse(char *begin, char *end)
{
char temp;
while (begin < end)
{
temp = *begin;
*begin++ = *end;
*end-- = temp;
}
}
/* Driver function to test above functions */
int main()
{
char s[] = "i like this program very much";
char *temp = s;
reverseWords(s);
printf("%s", s);
getchar();
return 0;
}
The above code doesn t handle the cases when the string starts with space. The fol
lowing version handles this specific case and doesn t make unnecessary calls to re
verse function in the case of multiple space in between. Thanks to rka143 for pr
oviding this version.
void reverseWords(char *s)
{
char *word_begin = NULL;
char *temp = s; /* temp is for word boundry */
/*STEP 1 of the above algorithm */
while( *temp )
{
/*This condition is to make sure that the string start with
valid character (not space) only*/
if (( word_begin == NULL ) && (*temp != ' ') )
{
word_begin=temp;
}
if(word_begin && ((*(temp+1) == ' ') || (*(temp+1) == '\0')))
{
reverse(word_begin, temp);
word_begin = NULL;
}
temp++;
} /* End of while */