Friday, 6 March 2015

Practice Test 1 : Quantitative Aptitude

Solve the following and check with the answers given at the end.
--------------------------------------------------------------------------------------------------------------------------------------
1. It was calculated that 75 men could complete a piece of work in 20 days. When work was scheduled to commence, it was found necessary to send 25 men to another project. How much longer will it take to complete the work?
--------------------------------------------------------------------------------------------------------------------------------------
2. A student divided a number by 2/3 when he required to multiply by 3/2. Calculate the percentage of error in his result.
--------------------------------------------------------------------------------------------------------------------------------------
3. A dishonest shopkeeper professes to sell pulses at the cost price, but he uses a
false weight of 950gm. for a kg. His gain is ...%.
--------------------------------------------------------------------------------------------------------------------------------------
4. A software engineer has the capability of thinking 100 lines of code in five
minutes and can type 100 lines of code in 10 minutes. He takes a break for five
minutes after every ten minutes. How many lines of codes will he complete typing after an hour?
--------------------------------------------------------------------------------------------------------------------------------------
5. A man was engaged on a job for 30 days on the condition that he would get a
wage of Rs. 10 for the day he works, but he have to pay a fine of Rs. 2 for each
day of his absence. If he gets Rs. 216 at the end, he was absent for work for ...
days.
--------------------------------------------------------------------------------------------------------------------------------------
6. A contractor agreeing to finish a work in 150 days, employed 75 men each
working 8 hours daily. After 90 days, only 2/7 of the work was completed.
Increasing the number of men by ________ each working now for 10 hours daily,
the work can be completed in time.
--------------------------------------------------------------------------------------------------------------------------------------
7. what is a percent of b divided by b percent of a?
(a) a
(b) b
(c) 1
(d) 10
(e) 100
--------------------------------------------------------------------------------------------------------------------------------------
8.A man bought a horse and a cart. If he sold the horse at 10 % loss and the cart at 20 % gain, he would not lose anything; but if he sold the horse at 5% loss and the cart at 5% gain, he would lose Rs. 10 in the bargain. The amount paid by him was
Rs._______ for the horse and Rs.________ for the cart.
 --------------------------------------------------------------------------------------------------------------------------------------
9. A tennis marker is trying to put together a team of four players for a tennis
tournament out of seven available. males - a, b and c; females – m, n, o and p. All
players are of equal ability and there must be at least two males in the team. For a team of four, all players must be able to play with each other under the following restrictions:
b should not play with m,
c should not play with p, and
a should not play with o.
Which of the following statements must be false?
1. b and p cannot be selected together
2. c and o cannot be selected together
3. c and n cannot be selected together.
--------------------------------------------------------------------------------------------------------------------------------------
10-12.
The following figure depicts three views of a cube. Based on this, answer
questions 10-12.
10. The number on the face opposite to the face carrying 1 is _______ .
--------------------------------------------------------------------------------------------------------------------------------------
11. The number on the faces adjacent to the face marked 5 are _______ .
--------------------------------------------------------------------------------------------------------------------------------------
12. Which of the following pairs does not correctly give the numbers on the opposite faces.
(1) 6,5
(2) 4,1
(3) 1,3
(4) 4,2
--------------------------------------------------------------------------------------------------------------------------------------
13. Five farmers have 7, 9, 11, 13 & 14 apple trees, respectively in their orchards. Last year, each of them discovered that every tree in their own orchard bore exactly the same number of apples. Further, if the third farmer gives one apple to the first, and the fifth gives three to each of the second and the fourth, they would all have exactly the same number of apples. What were the yields per tree in the orchards of the third and fourth farmers?
--------------------------------------------------------------------------------------------------------------------------------------
14. Five boys were climbing a hill. J was following H. R was just ahead of G. K was between G & H. They were climbing up in a column. Who was the second?
--------------------------------------------------------------------------------------------------------------------------------------
15-18 John is undecided which of the four novels to buy. He is considering a spy
thriller, a Murder mystery, a Gothic romance and a science fiction novel. The
books are written by Rothko, Gorky, Burchfield and Hopper, not necessary in that order, and published by Heron, Piegon, Blueja and sparrow, not necessary in that order.
(1) The book by Rothko is published by Sparrow.
(2) The Spy thriller is published by Heron.
(3) The science fiction novel is by Burchfield and is not published by Blueja.
(4)The Gothic romance is by Hopper.
15. Pigeon publishes ____________.
--------------------------------------------------------------------------------------------------------------------------------------
16. The novel by Gorky ________________.
--------------------------------------------------------------------------------------------------------------------------------------
17. John purchases books by the authors whose names come first and third in
alphabetical order. He does not buy the books ______.
--------------------------------------------------------------------------------------------------------------------------------------
18. On the basis of the first paragraph and statement (2), (3) and (4) only, it is
possible to deduce that
1. Rothko wrote the murder mystery or the spy thriller
2. Sparrow published the murder mystery or the spy thriller
3. The book by Burchfield is published by Sparrow.
--------------------------------------------------------------------------------------------------------------------------------------
19. If a light flashes every 6 seconds, how many times will it flash in 3⁄4 of an hour?
--------------------------------------------------------------------------------------------------------------------------------------
20. If point P is on line segment AB, then which of the following is always true?
(1) AP = PB 
(2) AP > PB 
(3) PB > AP 
(4) AB > AP 
(5) AB > AP + PB
--------------------------------------------------------------------------------------------------------------------------------------
21. All men are vertebrates. Some mammals are vertebrates. Which of the following conclusions drawn from the above statement is correct.
(a) All men are mammals
(b) All mammals are men
(c) Some vertebrates are mammals.
(d) None
--------------------------------------------------------------------------------------------------------------------------------------
22. Which of the following statements drawn from the given statements are correct?
Given: All watches sold in that shop are of high standard. Some of the HMT watches are sold in that shop.
a) All watches of high standard were manufactured by HMT.
b) Some of the HMT watches are of high standard.
c) None of the HMT watches is of high standard.
d) Some of the HMT watches of high standard are sold in that shop.
--------------------------------------------------------------------------------------------------------------------------------------
Given Data,
23-27.
1. Ashland is north of East Liverpool and west of Coshocton.
2. Bowling green is north of Ashland and west of Fredericktown.
3. Dover is south and east of Ashland.
4. East Liverpool is north of Fredericktown and east of Dover.
5. Fredericktown is north of Dover and west of Ashland.
6. Coshocton is south of Fredericktown and west of Dover.
--------------------------------------------------------------------------------------------------------------------------------------
23. Which of the towns mentioned is furthest of the north – west
(a) Ashland
(b) Bowling green
(c) Coshocton
(d) East Liverpool
(e) Fredericktown
--------------------------------------------------------------------------------------------------------------------------------------
24. Which of the following must be both north and east of Fredericktown?
(a) Ashland
(b) Coshocton
(c) East Liverpool
I a only
II b only
III c only
IV a & b
V a & c
--------------------------------------------------------------------------------------------------------------------------------------
25. Which of the following towns must be situated both south and west of at least one other town?
A. Ashland only
B. Ashland and Fredericktown
C. Dover and Fredericktown
D. Dover, Coshocton and Fredericktown
E. Coshocton, Dover and East Liverpool.
--------------------------------------------------------------------------------------------------------------------------------------
26. Which of the following statements, if true, would make the information in the numbered statements more specific?
(a) Coshocton is north of Dover.
(b) East Liverpool is north of Dover
(c) Ashland is east of Bowling green.
(d) Coshocton is east of Fredericktown
(e) Bowling green is north of Fredericktown
--------------------------------------------------------------------------------------------------------------------------------------
27. Which of the numbered statements gives information that can be deduced from one or more of the other statements?
(A) 1
(B) 2
(C) 3
(D) 4
(E) 6
--------------------------------------------------------------------------------------------------------------------------------------
28. Eight friends Harsha, Fakis, Balaji, Eswar, Dhinesh, Chandra, Geetha, and
Ahmed are sitting in a circle facing the center. Balaji is sitting between Geetha
and Dhinesh. Harsha is third to the left of Balaji and second to the right of
Ahmed. Chandra is sitting between Ahmed and Geetha and Balaji and Eshwar are not sitting opposite to each other. Who is third to the left of Dhinesh?
--------------------------------------------------------------------------------------------------------------------------------------
29. If every alternative letter starting from B of the English alphabet is written in small letter, rest all are written in capital letters, how the month ― September‖ be written.
(1) SeptEMbEr 
(2) SEpTeMBEr 
(3) SeptembeR
(4) SepteMber
(5) None of the above.
--------------------------------------------------------------------------------------------------------------------------------------
30. The length of the side of a square is represented by x+2. The length of the side of an equilateral triangle is 2x. If the square and the equilateral triangle have equal perimeter, then the value of x is _______.
 --------------------------------------------------------------------------------------------------------------------------------------
31. It takes Mr. Karthik y hours to complete typing a manuscript. After 2 hours, he was called away. What fractional part of the assignment was left incomplete?
--------------------------------------------------------------------------------------------------------------------------------------
32. Which of the following is larger than 3/5?
(1) 1⁄2
(2) 39/50 
(3) 7/25
(4) 3/10
(5) 59/100
--------------------------------------------------------------------------------------------------------------------------------------
33. The number that does not have a reciprocal is ____________.
--------------------------------------------------------------------------------------------------------------------------------------
34. There are 3 persons Sudhir, Arvind, and Gauri. Sudhir lent cars to Arvind and Gauri as many as they had already. After some time Arvind gave as many cars to Sudhir and Gauri as many as they have. After sometime Gauri did the same thing. At the end of this transaction each one of them had 24. Find the cars each originally had.
--------------------------------------------------------------------------------------------------------------------------------------
35. A man bought a horse and a cart. If he sold the horse at 10 % loss and the cart at 20 % gain, he would not lose anything; but if he sold the horse at 5% loss and the cart at 5% gain, he would lose Rs. 10 in the bargain. The amount paid by him was Rs._______ for the horse and Rs.________ for the cart.
--------------------------------------------------------------------------------------------------------------------------------------

C Aptitude Part VIII

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:
---------------------------------------------------------------------------------------------------------------------------------------
161)
#define assert(cond) if(!(cond)) \
(fprintf(stderr, "assertion failed: %s, file %s, line %d \n",#cond,\
__FILE__,__LINE__), abort())
void main()
{
int i = 10;
if(i==0)
assert(i < 100);
else
printf("This statement becomes else for if in assert macro");
}
Answer:
No output
Explanation:
The else part in which the printf is there becomes the else for if in the assert
macro. Hence nothing is printed.
The solution is to use conditional operator instead of if statement,
#define assert(cond) ((cond)?(0): (fprintf (stderr, "assertion failed: \ %s, file %s,
line %d \n",#cond, __FILE__,__LINE__), abort()))
Note:
However this problem of ―matching with nearest else‖ cannot be solved
by the usual method of placing the if statement inside a block like this,
#define assert(cond) { \
if(!(cond)) \
(fprintf(stderr, "assertion failed: %s, file %s, line %d \n",#cond,\
__FILE__,__LINE__), abort()) \
}
---------------------------------------------------------------------------------------------------------------------------------------
162)
Is the following code legal?
struct a
{
int x;
struct a b;
}
Answer:
No
Explanation:
Is it not legal for a structure to contain a member that is of the same
type as in this case. Because this will cause the structure declaration to be
recursive without end.
---------------------------------------------------------------------------------------------------------------------------------------
163) Is the following code legal?
struct a
{
int x;
struct a *b;
}
Answer:
Yes.
Explanation:
*b is a pointer to type struct a and so is legal. The compiler knows, the
size of the pointer to a structure even before the size of the structure
is determined(as you know the pointer to any type is of same size). This
type of structures is known as  ̳self-referencing‘ structure.
---------------------------------------------------------------------------------------------------------------------------------------
164) Is the following code legal?
typedef struct a
{
int x;
aType *b;
}aType
Answer:
No
Explanation:
The typename aType is not known at the point of declaring the structure
(forward references are not made for typedefs).
---------------------------------------------------------------------------------------------------------------------------------------
165) Is the following code legal?
typedef struct a aType;
struct a
{
int x;
aType *b;
};
Answer:
Yes
Explanation:
The typename aType is known at the point of declaring the structure,
because it is already typedefined.
---------------------------------------------------------------------------------------------------------------------------------------
166) Is the following code legal?
void main()
{
typedef struct a aType;
aType someVariable;
struct a
{
int x;
aType *b;
};
}
Answer:
No
Explanation:
When the declaration,
typedef struct a aType;
is encountered body of struct a is not known. This is known as  ̳incomplete
types‘.
---------------------------------------------------------------------------------------------------------------------------------------
167) void main()
{
printf(―sizeof (void *) = %d \n―, sizeof( void *));
printf(―sizeof (int *) = %d \n‖, sizeof(int *));
printf(―sizeof (double *) = %d \n‖, sizeof(double *));
printf(―sizeof(struct unknown *) = %d \n‖, sizeof(struct unknown *));
}
Answer
:
sizeof (void *) = 2
sizeof (int *) = 2
sizeof (double *) = 2
sizeof(struct unknown *) = 2
Explanation:
The pointer to any type is of same size.
---------------------------------------------------------------------------------------------------------------------------------------
168) char inputString[100] = {0};
To get string input from the keyboard which one of the following is better?
1) gets(inputString)
2) fgets(inputString, sizeof(inputString), fp)
Answer & Explanation:
The second one is better because gets(inputString) doesn't know the size
of the string passed and so, if a very big input (here, more than 100 chars)
the charactes will be written past the input string. When fgets is used with
stdin performs the same operation as gets but is safe.
---------------------------------------------------------------------------------------------------------------------------------------
169) Which version do you prefer of the following two,
1) printf(―%s‖,str); // or the more curt one
2) printf(str);
Answer & Explanation:
Prefer the first one. If the str contains any format characters like %d then
it will result in a subtle bug.
---------------------------------------------------------------------------------------------------------------------------------------
170) void main()
{
int i=10, j=2;
int *ip= &i, *jp = &j;
int k = *ip/*jp;
printf(―%d‖,k);
}
Answer:
Compiler Error: ―Unexpected end of file in comment started in line 5‖.
Explanation:
The programmer intended to divide two integers, but by the ―maximum munch‖ rule, the compiler treats the operator sequence / and * as /* which happens to be the starting of comment. To force what is intended by the programmer,
int k = *ip/ *jp;
// give space explicity separating / and *
//or
int k = *ip/(*jp);
// put braces to force the intention
will solve the problem.
---------------------------------------------------------------------------------------------------------------------------------------
171) void main()
{
char ch;
for(ch=0;ch<=127;ch++)
printf(―%c %d \n―, ch, ch);
}
Answer:
Implementation dependent
Explanation:
The char type may be signed or unsigned by default. If it is signed then
ch++ is executed after ch reaches 127 and rotates back to -128. Thus ch is
always smaller than 127.
---------------------------------------------------------------------------------------------------------------------------------------
172) Is this code legal?
int *ptr;
ptr = (int *) 0x400;
Answer:
Yes
Explanation:
The pointer ptr will point at the integer in the memory location 0x400.
---------------------------------------------------------------------------------------------------------------------------------------
173)
main()
{
char a[4]="HELLO";
printf("%s",a);
}
Answer:
Compiler error: Too many initializers
Explanation:
The array a is of size 4 but the string constant requires 6 bytes to get stored.
---------------------------------------------------------------------------------------------------------------------------------------
174)
main()
{
char a[4]="HELL";
printf("%s",a);
}
Answer:
HELL%@!~@!@???@~~!
Explanation:
The character array has the memory just enough to hold the string ―HELL‖ and doesnt have enough space to store the terminating null character. So it prints the HELL correctly and continues to print garbage values till it accidentally comes across a NULL character.
 ---------------------------------------------------------------------------------------------------------------------------------------
175)
main()
{
int a=10,*j;
void *k;
j=k=&a;
j++;
k++;
printf("\n %u %u ",j,k);
}
Answer:
Compiler error: Cannot increment a void pointer
Explanation:
Void pointers are generic pointers and they can be used only when the
type is not known and as an intermediate address storage type. No pointer
arithmetic can be done on it and you cannot apply indirection operator (*)
on void pointers.
---------------------------------------------------------------------------------------------------------------------------------------

177)
Printf can be implemented by using __________ list.
Answer:
Variable length argument lists
---------------------------------------------------------------------------------------------------------------------------------------
178) char *someFun()
{
char *temp = ―string constant";
return temp;
}
int main()
{
puts(someFun());
}
Answer:
string constant
Explanation:
The program suffers no problem and gives the output correctly because the
character constants are stored in code/data area and not allocated in stack, so this doesn‘t lead to dangling pointers.
---------------------------------------------------------------------------------------------------------------------------------------
179)
char *someFun1()
{
char temp[ ] = ―string";
return temp;
}
char *someFun2()
{
char temp[ ] = { ̳s‘,  ̳t‘,‘r‘,‘i‘,‘n‘,‘g‘};
return temp;
}
int main()
{
puts(someFun1());
puts(someFun2());
}
Answer:
Garbage values.
Explanation:
Both the functions suffer from the problem of dangling pointers. In someFun1()
temp is a character array and so the space for it is allocated in heap and is initialized with character string ―string‖. This is created dynamically as the function is called, so is also deleted dynamically on exiting the function so the string data is not available in the calling function main() leading to print some garbage values. The function someFun2() also suffers from the same problem but the problem can be easily identified in this case.
 ---------------------------------------------------------------------------------------------------------------------------------------