Professional Documents
Culture Documents
com/written-test-1/
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
18 19 20
Answered Review
1. Question
function (string)
{
If length of string > 5
return length*(length-1)
else
return length*(length+1)
}
function ("Test") = 12
function ("Testing") = 40
function("Test") = 20
function("Testing") = 30
2. Question
function f(num)
{
product = 1
for (i=num, i>0, i--)
{
product = (product) * (i) * (i-1)
https://automation-hiring.tracxn.com/written-test-1/ 1/11
03/09/2020 https://automation-hiring.tracxn.com/written-test-1/
}
return product
}
f(3) = f(4) = -1
f(3) = f(4) = 0
f(3) = f(4) = 2
f(3) = f(4) = 1
3. Question
x++; x--;
4. Question
Function (i,j)
{
if j is odd
j--
else
i++
return i+j
}
https://automation-hiring.tracxn.com/written-test-1/ 2/11
03/09/2020 https://automation-hiring.tracxn.com/written-test-1/
5. Question
18
24
23
21
6. Question
https://automation-hiring.tracxn.com/written-test-1/ 3/11
03/09/2020 https://automation-hiring.tracxn.com/written-test-1/
7. Question
function(num)
{
int sum;
if(num == 0)
{
return sum;
}
else
{
sum = num + function(num-1)
}
return sum;
}
function(6) = 21
function(5) = 14
function(3) = 5
function(7) = 21
8. Question
9. Question
10. Question
function (str)
{
for(i = 0; i < str.length - 1; i+2)
{
str2 = char at str[i] + str2;
}
return str2;
Testing
isT
gnitseT
gisT
11. Question
https://automation-hiring.tracxn.com/written-test-1/ 5/11
03/09/2020 https://automation-hiring.tracxn.com/written-test-1/
12. Question
Function (i,j)
{
k = 0;
For i > j
{
k = k + i*j
j++
}
return k
}
https://automation-hiring.tracxn.com/written-test-1/ 6/11
03/09/2020 https://automation-hiring.tracxn.com/written-test-1/
13. Question
Get age
if (?) then
Display "Teenager"
14. Question
function (string)
{
j=0;
for ( i < len of string )
{
if (char at string(i) = "a")
j++
}
return j
}
function ("TRACXN") = 1
function ("Testing") = 2
https://automation-hiring.tracxn.com/written-test-1/ 7/11
03/09/2020 https://automation-hiring.tracxn.com/written-test-1/
function ("Trial") = 1
function ("Home") = 3
15. Question
num = 0;
for(i=2;i>=1;i--)
{
for(j=0;j< i;j++)
num = num + i;
}
num = 5
num = 14
num = 55
num = 30
16. Question
function (i,j)
{
Do while (i<j)
{
i++;
j--;
if (i == j)
return i;
}
}
https://automation-hiring.tracxn.com/written-test-1/ 8/11
03/09/2020 https://automation-hiring.tracxn.com/written-test-1/
function(0,10) = 5
function(1,8) = 5
function(5,9) = function(6,8)
function(0,8) = 4
17. Question
(b) For each character in the sentence, if it is vowel then add to output array.
Return the array when its length is 10
Both (a) and (b) will not give the required output
(a) For each character in the sentence, if it is vowel then add to output array.
Return the rst 10 elements of the output array
18. Question
function (num)
{
x = 0;
if (num > 0)
{
num--
x = function(num)
num--
x = x + num
}
return x
}
https://automation-hiring.tracxn.com/written-test-1/ 9/11
03/09/2020 https://automation-hiring.tracxn.com/written-test-1/
function(3) = 1
function(4) = 2
function(4) = 5
function(3) = 2
19. Question
20. Question
function (i,j)
{
k = 0;
if(i < j)
{
i++;
j--;
k = i * j;
}
else
{
i--;
j++;
k = i * j;
}
k = k + (i-j);
https://automation-hiring.tracxn.com/written-test-1/ 10/11
03/09/2020 https://automation-hiring.tracxn.com/written-test-1/
return k;
}
https://automation-hiring.tracxn.com/written-test-1/ 11/11