Monday, March 19, 2007

Aptitude Questions-II

hi friends,

these are a set of placement aptitude questions which is mainly based on c lets see if u r able to solve them(ps:without seeing the answers given below)

Note : All the programs are tested under Turbo C/C++ compilers.
It is assumed that,
Ø Programs run under DOS environment,
Ø The underlying machine is an x86 system,
Ø Program is compiled using Turbo C/C++ compiler.
The program output may depend on the information based on this assumptions (for example sizeof(int) == 2 may be assumed).

Predict the output or error(s) for the following:

1. void main()
{
int const * p=5;
printf("%d",++(*p));
}
Answer:
Compiler error: Cannot modify a constant value.
Explanation:
p is a pointer to a "constant integer". But we tried to change the value of the "constant integer".

2. main()
{
char s[ ]="man";
int i;
for(i=0;s[ i ];i++)
printf("\n%c%c%c%c",s[ i ],*(s+i),*(i+s),i[s]);
}
Answer:
mmmm
aaaa
nnnn
Explanation:
s[i], *(i+s), *(s+i), i[s] are all different ways of expressing the same idea. Generally array name is the base address for that array. Here s is the base address. i is the index number/displacement from the base address. So, indirecting it with * is same as s[i]. i[s] may be surprising. But in the case of C it is same as s[i].

3. main()
{
float me = 1.1;
double you = 1.1;
if(me==you)
printf("I love U");
else
printf("I hate U");
}
Answer:
I hate U
Explanation:
For floating point numbers (float, double, long double) the values cannot be predicted exactly. Depending on the number of bytes, the precession with of the value represented varies. Float takes 4 bytes and long double takes 10 bytes. So float stores 0.9 with less precision than long double.
Rule of Thumb:
Never compare or at-least be cautious when using floating point numbers with relational operators (== , >, <, <=, >=,!= ) .

4. main()
{
static int var = 5;
printf("%d ",var--);
if(var)
main();
}
Answer:
5 4 3 2 1
Explanation:
When static storage class is given, it is initialized once. The change in the value of a static variable is retained even between the function calls. Main is also treated like any other ordinary function, which can be called recursively.

5. main()
{
int c[ ]={2.8,3.4,4,6.7,5};
int j,*p=c,*q=c;
for(j=0;j<5;j++) {
printf(" %d ",*c);
++q; }
for(j=0;j<5;j++){
printf(" %d ",*p);
++p; }
}

Answer:
2 2 2 2 2 2 3 4 6 5
Explanation:
Initially pointer c is assigned to both p and q. In the first loop, since only q is incremented and not c , the value 2 will be printed 5 times. In second loop p itself is incremented. So the values 2 3 4 6 5 will be printed.

Sunday, March 18, 2007

Placement Aptitude Questions & Answers

















Infosys Test #1

1. Father's age is three years more than three times the son's age.
After three years, father's age will be ten years more than twice
the
son's age.
What is the father's present age.

Ans: 33 years. (2 marks)

2. Find the values of each of the alphabets.

N O O N
S O O N
+ M O O N
----------
J U N E

Ans: 9326 (2 marks)
3. There are 20 poles with a constant distance between each pole
A car takes 24 second to reach the 12th pole.
How much will it take to reach the last pole.

Ans: 41.45 seconds (2 marks)
Let the distance between two poles = x
Hence 11x:24::19x:?


4. A car is travelling at a uniform speed.
The driver sees a milestone showing a 2-digit number.
After travelling for an hour the driver sees another milestone
with the
same digits in reverse order.
After another hour the driver sees another milestone containing
the
same two digits.
What is the average speed of the driver.

Ans: 45 kmph (4 marks)


5. The minute and the hour hand of a watch meet every 65 minutes.
How much does the watch lose or gain time and by how much?

Ans: Gains; 5/11 minutes (4 marks)


6. Ram, Shyam and Gumnaam are friends.
Ram is a widower and lives alone and his sister takes care of him.
Shyam is a bachelor and his neice cooks his food and looks after
his
house.
Gumnaam is married to Gita and lives in large house in the same
town.
Gita gives the idea that all of them could stay together in the
house
and share monthly expenses equally.
During their first month of living together, each person
contributed
Rs.25.
At the end of the month, it was found that Rs 92 was the expense so
the
remaining amount was distributed equally
among everyone.
The distribution was such that everyone recieved a whole number of
Rupees.
How much did each person recieve?

Ans. Rs 2 (4 marks)
(Hint: Ram's sister, Shyam's neice and Gumnaam's wife are the
same
person)


7. Four persons A, B, C and D are playing cards.
Each person has one card, laid down on the table below him, which
has
two different colours on either side.
The colours visible on the table are Red, Green, Red and Blue.
They see the color on the reverse side and give the following
comment.

A: Yellow or Green
B: Neither Blue nor Green
C: Blue or Yellow
D: Blue or Yellow

Given that out of the 4 people 2 always lie find out the colours on the
cards each person.


------------------------------------------------------------------------------------- Infosys Test #2




1. At 6'o a clock ticks 6 times.
The time between first and last ticks is 30 seconds.
How long does it tick at 12'o clock.

Ans: 66 sec. (2 marks)


2. Three friends divided some bullets equally.
After all of them shot 4 bullets the total number of bullets
remaining
is equal to the bullets each had after division.
Find the original number divided.

Ans: 18 (2 marks)

Initially . x x x
Now x-4 x-4 x-4
Equation is 3x-12 = x


3. A ship went on a voyage.
After it had travelled 180 miles a plane statrted with 10 times the
speed of the ship.
Find the distance when they meet from starting point.

Ans: 200miles. (2 marks)
Distance travelled by plane = 1/10 distance travelled by ship +
180


4.There are 3 societies A, B, C.
A lent cars to B and C as many as they had already.
After some time B gave as many tractors to A and C
as many as they have. After sometime c did the same thing. At the end
of
this transaction each one of them had 24.
Find the cars each orginally had.

Ans: A had 39 cars, B had 21 cars & C had 12 cars (4
marks)


6. There N stations on a railroad.
After adding X stations on the rail route 46 additional tickets
have to
be printed.
Find N and X.

Ans. x=2 and N=11

Let initially, N(N-1) = t
After adding, (N+X)(N+X-1) = t+46
By trail and error method (4
marks)


7. Given that April 1 is tuesday.
A, B, C are 3 persons told that their farewell party was on

A - May 8, thursday
B - May 10,tuesday
C - June 5, friday

Out of A, B, C only one made a completetly true statement concerning
date,day and month
The other told two one told the day right and the other the date
right..
What is correct date, month, day.

Ans: B - (May 10) SUNDAY
C - June 6 (Friday). (5
marks)


8. The Bulls, Pacers, Lakers and Jazz ran for a contest.
Anup, Sujit, John made the following statements regarding results.

Anup said either Bulls or Jazz will definitely win
Sujit said he is confident that Bulls will not win
John said he is confident that neither Jazz nor Lakers will win

When the result cameit was found that only one of the above three had
made a
correct statement.
Who has made the correct statement and who has won the contest.

Ans: Sujith; Lakers (5marks )


9. Five people A ,B ,C ,D ,E are related to each other.
Four of them make one true statement each as follows.

(i) B is my father's brother.
(ii) E is my mother-in-law.
(iii)C is my son-in-law's brother
(iv)A is my brother's wife.

Ans: (i) D
(ii) B
(iii) E
(iv) C (10 marks)


10. Some statements are given below:

L says all of my other four friends have money
M says that P said that exactly one among them has money
N says that L said that precisely two among them have money
O says that M said that three of the others have money
P, L and N said that they have money

All the above statement are false..
Who has money & who doesn't have any money?

(5 marks)

-------------------------------------------------------------------------------------
Infosys Test #3




1. Mr.Mathurs jewels have been stolen from his bank locker .
The bank has lockers of 12 people which are arranged in an array of
3
rows and 4 columns like:

1
2
3
4
5
6
7
8
9
10
11
12


The locker belonging to JONES was to the right of BLACK'S locker
and
directly above MILLAR'S.
BOOTH'S locker was directly above MILLAR'S.
SMITH'S locker was also above GRAY's (though not directly).
GREEN'S locker was directly below SMITH'S.
WILSON'S locker was between that of DAVIS and BOOTH.
MILLAR'S locker was on the bottom row directly to the right of
HERD'S.
WHITE'S locker was on the bottom right hand corner in the same
column
as BOOTH'S.

Which box belonged to Mr.Mathurs?

Ans: Box number 9 belongs to Mr.Mathurs.


2. Fifty minutes ago if it was four times as many minutes past three
o'clock,how many minutes is it to six o'clock?

Ans: Twenty six minutes.


3. If a clock takes 7seconds to strike 7, how long will the same clock
take
to strike 10?

Ans: The clock strikes for the first time at the start and takes 7
seconds
for 6 intervals-thus for one interval time
taken=7/6.
Therefore, for 10 seconds there are 9 intervals and time taken
is
9*7/6=10 and 1/2 seconds.


4. Three criminals were arrested for shop lifting.
However, when interrogated only one told the truth in both his
statements, while the other two each told one true
statement and one lie.
The statements were:

ALBERT :(a)Chander passed the merchandise. (b)Bruce created the
diversion.
BRUCE :(a)Albert passed the merchandise. (b)I created the
diversion.
CLIVE :(a)I took the goods out of the shop. (b)Bruce passed
them
over.

Ans: Albert passed the goods.Bruce created the diversion..Clive took
the
goods out of the shop.


5. Everyday in his business a merchant had to weigh amounts from 1 kg
to 121
kgs, to the nearest kg.
What are the minimum number of weight required and how heavy should
they
be?

Ans: .The minimum number is 5 and they should weigh 1,3,9,27 and 81
kgs.


6. A hotel has 10 storeys.Which floor is above the floor below the
floor,
below the floor above the floor, below the
floor above the fifth.

Ans: The sixth floor.


7. Seven members sat around a table for three days for a conference.
The member's names were Abhishek, Amol, Ankur, Anurag,Bhuwan ,Vasu
and
Vikram.
The meetings were chaired by Vikram.
On the first evening members sat around the table alphabetically.
On the following two nights, Vikram arranged the seatings so that
he
could have Abhishek as near to him as
possible and abesent minded Vasu as far away as he could.
On no evening did any person have sitting next to him a person who
had
previously been his neighbour.
How did Vikram manage to seat everybody to the best advantage on
the
second and third evenings?

Ans:
Second evening:Vikram,Ankur,Abhishek,Amol,Vasu,Anurag and Bhuwan.
Third evening :Vikram,Anurag,Abhishek,Vasu,Bhuwan,Ankur,Amol.


8. Two trains start from stations A and B spaced 50 kms apart at the
same
time and speed.
As the trains start, a bird flies from one train towards the other
and
on reaching the second train, it flies back to the
first train.This is repeated till the trains collide.
If the speed of the trains is 25 km/h and that of the bird is
100km/h.
How much did the bird travel till the collision.

Ans: 100 kms.


9. Four prisoners escape from a prison.
The prisoners, Mr East, Mr West, Mr South, Mr North head towards
different directions after escaping.
The following information of their escape was supplied:

The escape routes were The North Road, South Road, East Road and
West
Road.
None of the prisoners took the road which was their namesake.
Mr.East did not take the South Road
Mr.West did not the South Road.
The West Road was not taken by Mr.East

What road did each of the prisoners take to make their escape?

Ans: Mr.East took the North Road
Mr.West took the East Road
Mr.North took the South Road
Mr.South took the West Road.


10. Complete the series:
5, 20, 24, 6, 2, 8, ?

Ans: 12 (as 5*4=20, 20+4=24, 24/4=6, 6-4=2, 2*4=8, 8+4=12).


------------------------------------------------------------------------------------- Infosys Test #4




1. Replace each letter by a digit.
Each letter must be represented by the same digit and no beginning
letter of a word can be 0.

O N E
O N E
O N E
O N E
-------
T E N

Ans: 0 =1, N = 8 ,E = 2, T = 7



2. Ann, Boobie, Cathy and Dave are at their monthly business meeting.
Their occupations are author, biologist, chemist and doctor, but
not
necessarily in that order.
Dave just told the biologist that Cathy was on her way with
doughnuts.
Ann is sitting across from the doctor and next to the chemist.
The doctor was thinking that Boobie was a goofy name for parent's
to
choose,but didn't say anything.
What is each person's occupation?

Ans: Since Dave spoke to the biologist and Ann sat next to the chemist
and
across the doctor, Cathy must be the author
and Ann the biologist.
The doctor didn't speak, but David did, so Bobbie is the doctor
and
Dave the chemist.



3. Sometime after 10:00 PM a murder took place.
A witness claimed that the clock must have stopped at the time of
the
shooting.
It was later found that the postion of both the hands were the same
but
their positions had interchanged.
Tell the time of the shooting (both actual and claimed).

Ans: Time of shooting = 11:54 PM
Claimed Time = 10:59 PM



4. Next number in the series is
1 , 2 , 4 , 13 , 31 , 112 , ?

Ans: 224.
No number has digits more than 4. All of them are 1 , 2, 4, 8 ,
16 ,
32 , 64 converted to numbers in base 5



5. Shahrukh speaks truth only in the morning and lies in the afternoon,
whereas Salman speaks truth only in the afternoon. A
says that B is Shahrukh. Is it morning or afternoon and who is A -
Shahrukh
or Salman.

Ans: Afternoon ; A is Salman.



6. Two trains starting at same time, one from Bangalore to Mysore and
other
in opposite direction arrive at their
destination 1 hr and 4 hours respectively after passing each other.
How
nuch faster is one train from other?

Ans: Twice



7. There are 6 volumes of books on a rack kept in order ( ie vol.1,
vol. 2
and so on ).
Give the position after the following changes were noticed.

All books have been changed
Vol.5 was directly to the right of Vol.2
Vol.4 has Vol.6 to its left and both weren't at Vol.3's place
Vol.1 has Vol.3 on right and Vol.5 on left
An even numbered volume is at Vol.5's place

Find the order in which the books are kept now.

Ans: 2 , 5 , 1 , 3 , 6 , 4



8. I bought a car with a peculiar 5 digit numbered licence plate which
on
reversing could still be read.
On reversing value is increased by 78633.Whats the original number
if
all digits were different?

Ans: Only 0 1 6 8 and 9 can be readupside down.So on rearranging these
digits we get the answer as 10968



9. The shape in the sketch below is that of a square attached to half
of a
similar square.Divide it into four equal pieces



Ans: Hint : the figure can be divided into 12 equal triangles



10. Supposing a clock takes 7 seconds to strike 7. How mlong will it
take to
strike 10?

Ans: 10 1/2 seconds.
-------------------------------------------------------------------------------------there are a lot more out there meet u in the next blog
WITH REGARDS
SURAI