You are on page 1of 11

03/09/2020 https://automation-hiring.tracxn.

com/written-test-1/

Automation Team - Written Test 1


RESULTS

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

Which of the following is true for the following code:


For a given number "num" > 0

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

Which of the sets of statements below will add 1 to x if x is positive


and subtract 1 from x if x is negative but leave x alone if x is 0?

If (x > 0) x++; else if (x < 0) x--;

If (x == 0) x = 0; else x++; x--;

x++; x--;

If (x > 0) x++; else x--;

4. Question

Function (i,j)
{
if j is odd
j--
else
i++
return i+j
}

Which of the following is True?

https://automation-hiring.tracxn.com/written-test-1/ 2/11
03/09/2020 https://automation-hiring.tracxn.com/written-test-1/

Options (b) and (c)

(c) if i and j are odd - Output of function (i,j) is always odd

(b) If i and j are even - Output of function (i,j) is always even

(a) Output of function (i,j) is always 0

5. Question

What is the output of this program?


function()
{
y = 4;
x = 10;
z = 5;
for(y < x)
{
x = x - 3;
y = y - 1;
z = z + x + y;
}
return z;
}

What is the output of this function ?

18

24

23

21

6. Question

We have an array of continuous and unsorted numbers from 0 to n. We don't


know n. Which of the following will give us n

The last element in the array

https://automation-hiring.tracxn.com/written-test-1/ 3/11
03/09/2020 https://automation-hiring.tracxn.com/written-test-1/

The length of the array

The length of the array + 1

The length of the array - 1

7. Question

function(num)
{
int sum;

if(num == 0)
{
return sum;
}
else
{
sum = num + function(num-1)
}
return sum;
}

Which of the following is True?

function(6) = 21

function(5) = 14

function(3) = 5

function(7) = 21

8. Question

We have a set of continuous even numbers. For a function to return the


sum of these numbers what is the optimal input required

The total count of the numbers

All the numbers

The start number and the total count of the numbers


https://automation-hiring.tracxn.com/written-test-1/ 4/11
03/09/2020 https://automation-hiring.tracxn.com/written-test-1/

The start number

9. Question

Which of the following codes will enable function(4,2) = 2

(c) function (i,j) { k = j - i; L = 1; for k > 0 { k = k - i; L = L + i; } return L; }

(a) function (i,j) { k = i/2 return k }

Options (a), (b) and (c)

Options (a) and (b)

(b) function (i,j) { k = i - j return k }

10. Question

function (str)
{
for(i = 0; i < str.length - 1; i+2)
{
str2 = char at str[i] + str2;
}
return str2;

What is the output of function("Testing") ?

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/

Function (str as string)


{
For (i = 0 to len of str-1)
{
char a = str (i);
char b = str (len of str - i);
str(i) = b;
str(len of str - i) = a
}
return str
}

What does the above function do?

None of the options

Returns a reversed string

Returns the character most repeated in string

Returns the character in middle of the string

12. Question

Function (i,j)
{
k = 0;
For i > j
{
k = k + i*j
j++
}
return k
}

Function (10,8) = 190

https://automation-hiring.tracxn.com/written-test-1/ 6/11
03/09/2020 https://automation-hiring.tracxn.com/written-test-1/

Function (10,8) = 170

Function (10,8) = 180

Function (10,8) = 160

13. Question

Get age
if (?) then
Display "Teenager"

Which of the following statements can be replaced in (?) correctly ?

(*People with age of 13 yrs to 19 yrs are considered teenagers)

age >= 13 AND age <= 19

age > 13 AND age < 19

age >=13 OR age <= 19

age <= 13 AND age <= 19

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;
}
}

Which of the following is False?

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

We would like to return the first 10 vowels appearing in a sentence.


Which of the following functions will give us the output

Both (a) and (b) will give the required output

(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
}

Which of the following statements is True

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

Which of the following is equivalent to the following decision logic


if (x > 10)
if (y > x)
Display "y"

if (x > 10 OR y > x) then Display "y"

if (x > 10 AND x > y) then Display "y"

if (x > 10 AND y > x) then Display "y"

if (x > 10 AND y > 10) then Display "y"

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;
}

Which of the following is True

Options a, b and c are True

(c) function (2,4) = function (4,2)

(b) function (3, 3) = 0

(a) function (2,9) = 18

https://automation-hiring.tracxn.com/written-test-1/ 11/11

You might also like