Please login

Prime

Prepinsta Prime

Video courses for company/skill based Preparation

(Check all courses)
Get Prime Video
Prime

Prepinsta Prime

Purchase mock tests for company/skill building

(Check all mocks)
Get Prime mock

TCS Functions and Scope – 2 Questions with Answers

Question 1

Time: 00:00:00
Choose the correct answer
Saumya writes a code which has a function which calls itself. Which programming concept is Saumya using?

This is bad programming practice and should not be done.

This is bad programming practice and should not be done.

Recursion

Recursion

Decision Making

Decision Making

Overloading

Overloading

Once you attempt the question then PrepInsta explanation will be displayed.

Please login to submit your explanation

Recursion

Start

Question 2

Time: 00:00:00
Consider the following function

function calculate( n )
{
if(n equals 5)
return 5
else
return (n + calculate(n-5))
end
}

Shishir calls the function by the statement, calculate(20). What value will the function return?

50

50

200

200

35

35

20

20

Once you attempt the question then PrepInsta explanation will be displayed.

Please login to submit your explanation

Start

Question 3

Time: 00:00:00
Choose the correct answer
function g(int n)
{
if (n > 0) return 1;
else return -1;
}

function f(int a, int b)
{
if (a > b) return g(b-a);
if (a < b) return g(a-b);
return 0;
}

If f(a,b) is called, what is returned?

Always -1

Always -1

1 if a > b, -1 if a < b, 0 otherwise

1 if a > b, -1 if a < b, 0 otherwise

-1 if a > b, 1 if a < b, 0 otherwise

-1 if a > b, 1 if a < b, 0 otherwise

0 if a equals b, -1 otherwise

0 if a equals b, -1 otherwise

Once you attempt the question then PrepInsta explanation will be displayed.

Please login to submit your explanation

Start

Question 4

Time: 00:00:00
Choose the correct answer
Afzal writes a piece of code, where a set of three lines occur around 10 times in different parts of the program. What

programming concept can he use to shorten his program code length?

Use for loops

Use for loops

Use functions

Use functions

Use arrays

Use arrays

Use classes

Use classes

Once you attempt the question then PrepInsta explanation will be displayed.

Please login to submit your explanation

Start

Question 5

Time: 00:00:00
Talika wants to implement heterogeneous linked list for her project. Which of the following will help her do the same.

Void pointer

Void pointer

Null pointer

Null pointer

Wild pointer

Wild pointer

Heterogeneous list follows the same procedure as the homogeneous list. Hence no different pointer is required.

Heterogeneous list follows the same procedure as the homogeneous list. Hence no different pointer is required.

Once you attempt the question then PrepInsta explanation will be displayed.

Please login to submit your explanation

Start

["0","40","60","80","100"]
["Need more practice! \n \n","Keep trying! \n \n","Not bad! \n \n","Good work! \n \n","Perfect! \n \n"]
Hey ! Follow us on G+