VIRTUSA Previous Years Solved Sample Placement Papers
- Solution: `(*dpi)` is expected to point to the address of `pi`, not the value 100. Hence, Option D is incorrect.
-
Consider the following program fragment:
`int counter = 0, i; for (i = 0;; i++) { if (i < 100) continue; counter++; if (counter == 100) break; } printf("%d %d", i, counter);`
Results in:
(a) 199 100
(b) 200 100
(c) 199 99
(d) 200 0 Answer: Option A
- Solution: The loop iterates until `i` is 199 and `counter` reaches 100, making the output `199 100`.
-
Consider the array definition:
`int a[] = {10, 20, 30, 40};`
Identify the incorrect statement:
(a) Successive one-dimensional array elements in the array a[1], a[2] are located in contiguous memory space.
(b) a[1] and *(a+1) are the same.
(c) During initialization, array size must be specified; otherwise, a compile-time error occurs.
(d) &a[1] which has a+1 value, such as the address Answer: Option C
- Solution: An array can be initialized without specifying its size explicitly, as the size is inferred from the initializer.
-
Define `sqrt(x) x*x`
`sqrt(3-5);`
Results in:
Answer: -17
- Solution: The macro `sqrt(x)` expands to `(3-5)*(3-5)`, evaluating to `-17` due to incorrect usage of parentheses.
-
Define `true 1`, `false -1`, `null 0`:
The program:
`if(null) printf("..."); else if(false) printf("true");`
Results in:
Answer: True
- Solution: Since `null` is 0 (false), the condition falls to the `else if`, where `false (-1)` is treated as true.
-
The program fragment:
`int i = 10; switch (i) { printf("samsung"); case 10: printf("some string"); break; case 5*2: printf("some string"); break; }`
Results in:
Answer: Error due to conflicting case
- Solution: The case `10` and `5*2` conflict, causing a compilation error.
-
The program fragment:
`int i = 5, *j; void *k; k = j = &i; printf("%d", k + 1);`
Results in:
Answer: Compilation error
- Solution: Arithmetic operations are not allowed on `void` pointers unless explicitly cast, causing a compilation error.
-
Min sampling frequency for 20-20kHz analog signal is:
A. 20kHz
B. 40kHz Answer: Option B
C. 44.1kHz
D. 20Hz
-
If it costs x dollars for making a certain item if the quantity is 1000 and if the quantity increases, then the item is made using y dollars. If z number of items are made which are greater than 1000, then what is the total cost?
Ans: 1000(x - y) + yz
-
If the distance between two trains is 110KMs and two trains travel in opposite directions. If one starts at 7 AM and the other at 8 AM and their velocities are 20 and 25 KMPH, then they meet at:
Ans: 10 AM
-
A person is to go up a tree 60ft high. In every second, he climbs 5ft but slips 4ft. After how many seconds will he be able to touch the top of the tree?
1) 60
2) 59
3) 56
4) 58
-
A is 10 km from B and C is 17 km from B. Then which option is true:
A. A is in between B and C.
B. B is in between A and C.
C. C is in between A and B.
D. a and b Answer: Option D
-
Find out the number of 8's preceded by 5 but not just followed by 3 in the series (very easy question):
Series was something like this: 2158367983856787325839076 (but not correct)
Ans: 4 (sure)
-
Based on this situation, 4 questions were asked (these were very simple, do not miss to attempt):
Big university and small colleges decided to make committees for inspection. Each 3 member committee has 2 from university and one from small college.
In each committee, no two members belong to the same subject...
Now conditions: for university:
M--Maths teachers
L--English
K--Natural Science
For small college:
N--Maths
H--Hindi
O&P--English
-
Ques17: If M surveys, what other two members will be:
A. L, K
B. L, N
C. K, O Answer: Option C
D. none of the above
- Find the area of a circle if its radius is 3
A. 3𝜋
B. 6𝜋
C. 9𝜋
D. 𝜋
Answer: C - The cost of 8 fans and 14 ovens is Rs.36520. What is the cost of 12 fans and 21 ovens (in Rs.)?
1) Rs.56,800
2) Rs.54780
3) Rs.57950
4) Cannot be determined
5) None of these
Answer: 1) Rs.56,800 - The average of four consecutive odd numbers P, Q, R and S respectively (in increasing order) is 104. What is the sum of P and S?
1) 204
2) 208
3) 206
4) 212
5) None of these
Answer: 2) 208