**Answer:**

Que: Choose the correct answer

In a sequential programming language, code statements are executed in which order?

Option 1 : All are executed simultaneously

Option 2 : From top to bottom

Option 3 : From bottom to top

Option 4 : None of these

Ams-2

Que: Choose the correct answer

The construct “if (condition) then A else B” is for which of the following purposes?

Option 1 : Decision-Making

Option 2 : Iteration

Option 3 : Recursion

Option 4 : Object Oriented Programming

Ans-1

Que: Choose the correct answer

What does this function compute for positive n?

function f(int n)

{

if (n equals 1)

{ return 1 }

else

{ return f(n-1)/f(n-1) + n }

}

Option 1 : 1 + n

Option 2 : 1 + 2 + 3 + … + n

Option 3 : 1 + n, if n > 1, 1 otherwise

Option 4 : None of the above

Ans-3

Que: Choose the correct answer

int area(double radius)

{

return PI*radius*radius;

}

Que: Which of the following is always true about the function area?

Option 1 : It returns the area of a circle within the limits of double precision.

Option 2 : It returns the area of a circle within the limits of the constant PI.

Option 3 : It returns the area of a circle within the limits of precision of double, or the constant PI, whichever is lower.

Option 4 : None of the above.

Ans-1

Que: Choose the correct answer

Assuming n > 2, What value does the following function compute for odd n?

function f (int n)

{

if (n equals 1) { return 1 }

if (n equals 2) { return f(n-1) + n/2 }

return f(n-2) + n;

}

Option 1 : 1 + 2 + 3 + 4 + … + n

Option 2 : 1 + 3 + 5 + 7 + … + n

Option 3 : n/2 + (1 + 3 + 5 + 7 + … + n)

Option 4 : 1 + (1 + 3 + 5 + 7 + … + n)

Ans-2

Que: 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?