## Functions

 Question 1

Consider the following C program:

```         #include <stdio.h>
int jumble (int x, int y)  {
x = 2 * x + y ;
return x ;
}
int main ( )  {
int x=2, y=5 ;
y = jumble (y, x) ;
x = jumble (y, x) ;
printf ("%d \n", x) ;
return 0 ;
}
```

The value printed by the program is ______.

 A 26 B 67 C 25 D 13
Programming-for-Output-Problems       Functions       GATE 2019       Video-Explanation
Question 1 Explanation:
////////////////////////////////////Program
#include
int jumble(int x, int y)
{
printf("Inside jumble : 2*%d + %d\n", x,y);
x = 2*x +y;
return x;
}
int main()
{
int x=2, y=5;
printf("Initial x=%d, y=%d\n",x,y);
printf("1st jumble call : jumble(%d,%d)\n",y,x);
y = jumble(y,x);
printf("Value of y after 1st jumble = %d\n", y);
printf("2nd jumble call: jumble(%d,%d)\n", y,x);
x = jumble(y,x);
printf("Value of x after 2nd jumble = %d\n", x);
printf("Final : %d\n", x);
return 0;
}
////////////////////////////////////OUTPUT
Initial x=2, y=5
1st jumble call: jumble(5,2)
Inside jumble : 2*5 + 2
Value of y after 1st jumble = 12
2nd jumble call: jumble(12,2)
Inside jumble : 2*12 + 2
Value of x after 2nd jumble = 26
Final : 26
 Question 2

Consider the following C function.

```               void convert (int n) {
if (n < 0)
printf ("%d", n);
else {
convert (n/2);
printf ("%d", n%2);
}
}
```

Which one of the following will happen when the function convert is called with any positive integer n as argument?

 A It will print the binary representation of n in the reverse order and terminate. B It will not print anything and will not terminate. C It will print the binary representation of n and terminate. D It will print the binary representation of n but will not terminate.
Programming-for-Output-Problems       Functions       GATE 2019
Question 2 Explanation:
////////////////OUTPUT
Sequence of function calls
Convert(6)
Convert(3)
Convert(1)
Convert(0)
:
Convert(0)
:
:
It will not terminate and never produce any output.
Note:
There is no instruction which stops the loop.
 Question 3

How many onto (or surjective) functions are there from an n-element (n ≥ 2) set to a 2-element set?

 A 2n B 2n-1 C 2n-2 D 2(2n– 2)
Engineering-Mathematics       Functions       GATE 2012
Question 3 Explanation: Onto function is possible if m ≥ n. So, no. of onto functions possible is,
nm - nC1 (n-1)m + nC2 (n-2)m + .......
Here in Question,
m = n, n = 2
So, the final answer will be,
= 2n - 2C1 (2-1)n + 2C2 (2-2)n
= 2n - 2 × 1 + 0
= 2n - 2
 Question 4

Let A be a set of n(>0) elements. Let Nr be the number of binary relations on A and let Nf be the number of functions from A to A.

(a) Give the expression for Nr in terms of n.
(b) Give the expression for Nf in terms of n.
(c) Which is larger for all possible n, Nr or Nf?
 A Theory Explanation is given below.
Engineering-Mathematics       Functions       GATE 2002
 Question 5

On the set N of non-negative integers, the binary operation __________ is associative and non-commutative.

 A fog
Engineering-Mathematics       Functions       GATE 1994
Question 5 Explanation:
The most important associative operation that is not commutative is function composition. If you have two functions f and g, their composition, usually denoted fog, is defined by
(fog)(x) = f(g(x))
It is associative, (fog)oh = fo(goh), but its usually not commutative. fog is usually not equal to gof.
Note that if fog exists then gof might not even exists.
 Question 6

What function of x, n is computed by this program?

``` Function what (x, n:integer): integer:
Var
value : integer;
begin
value:=1
if n>0 then
begin
if n mod 2 = 1 then
value:=value*x;
value:=value*what(x*x, n div 2);
end;
what:value
end; ```
 A Theory Explanation.
Programming       Functions       GATE 1994
 Question 7

(a) Draw a precedence graph for the following sequential code. The statements are numbered from S1 to S6

``` S1       read n
S2       i:=1
S3       if i>n goto next
S4       a(i):=i+1
S5       i:=i+1
S6       next : Write a(i) ```

(b) Can this graph be converted to a concurrent program using parbegin-parend construct only?

 A Theory Explanation.
Programming       Functions       GATE 1994
 Question 8

Consider the following C functions.

```  int fun1 (int n)  {                              int fun2 (int n)  {
static int i = 0;                                static int i = 0;
if (n > 0)  {                                    if (n > 0)  {
++i;                                              i = i + fun1 (n);
fun1 (n-1);                                       fun2 (n-1);
}                                                 }
return (i);                                           return (i);
}                                                 } ```

The return value of fun2 (5) is _______.

 A 55
Programming       Functions       GATE 2020
Question 8 Explanation:
#include
int fun1(int n) {
printf("--fun1 call--\n");
static int i = 0;
if(n>0){
++i;
printf("fun1(%d-1)\n",n);
fun1(n-1);
}
printf("fun1(%d)= %d\n",n, i);
return(i);
}
int fun2(int n) {
printf("\n******* fun2 call ********\n");
static int i = 0;
if(n>0){
printf("%d + fun1(%d)\n", i,n);
i=i+fun1(n);
fun2(n-1);
}
printf("fun2(%d)= %d\n",n, i);
return(i);
}
void main()
{
printf("final = %d\n", fun2(5));
}
Check step by step hand run of the code to understand the recursion:
******* fun2 call ********
0 + fun1(5)
--fun1 call--
fun1(5-1)
--fun1 call--
fun1(4-1)
--fun1 call--
fun1(3-1)
--fun1 call--
fun1(2-1)
--fun1 call--
fun1(1-1)
--fun1 call--
fun1(0)= 5
fun1(1)= 5
fun1(2)= 5
fun1(3)= 5
fun1(4)= 5
fun1(5)= 5
******* fun2 call ********
5 + fun1(4)
--fun1 call--
fun1(4-1)
--fun1 call--
fun1(3-1)
--fun1 call--
fun1(2-1)
--fun1 call--
fun1(1-1)
--fun1 call--
fun1(0)= 9
fun1(1)= 9
fun1(2)= 9
fun1(3)= 9
fun1(4)= 9
******* fun2 call ********
14 + fun1(3)
--fun1 call--
fun1(3-1)
--fun1 call--
fun1(2-1)
--fun1 call--
fun1(1-1)
--fun1 call--
fun1(0)= 12
fun1(1)= 12
fun1(2)= 12
fun1(3)= 12
******* fun2 call ********
26 + fun1(2)
--fun1 call--
fun1(2-1)
--fun1 call--
fun1(1-1)
--fun1 call--
fun1(0)= 14
fun1(1)= 14
fun1(2)= 14
******* fun2 call ********
40 + fun1(1)
--fun1 call--
fun1(1-1)
--fun1 call--
fun1(0)= 15
fun1(1)= 15
******* fun2 call ********
fun2(0)= 55
fun2(1)= 55
fun2(2)= 55
fun2(3)= 55
fun2(4)= 55
fun2(5)= 55
final = 55
 Question 9
Consider the following C functions.
int tob (int b, int* arr) {
int i;
for (i=0; b>0; i++) {
if (b%2) arr [i] = 1;
else arr [i] = 0;
b = b/2;
}
return (i);
}

int pp (int a, int b) {
int arr ;
int i, tot = 1, ex, len;
ex = a;
len = tob (b,arr);
for (i=0; i if (arr[i] == 1)
tot = tot * ex;
ex = ex * ex;
}
return (tot);
}
The value returned by pp(3,4) is ________.
 A 81
Programming       Functions       GATE 2020
Question 9 Explanation:
pp(3,4) ⇒
a=3,b=4
tot=1
ex=a=3
len=tob(b,arr) which is 3
[
tob(4,arr)==>
b=4
b%2 =4%2=0 Condition is false then arr=0
=> b=b/2 =4/2 =2
b=2
b%2 =2%2=0 condition is false then arr=0
=>b=b/2=2/2=1
b=1
then b%2=1%2 condition is true then arr=1
=>b=b/2=1/2=0
The i value is 3 [length is 3]
]
i=0,
arr ==1 condition is false
ex=3*3=9
i=1
arr==1 condition is false
then
ex=9*9=81
i=2
then arr==1 condition is true
tot=tot*ex=1*81=81
ex=81*81
Finally it returns tot value which 81.
 Question 10

The function f(x,y) = x2y - 3xy + 2y + x has

 A no local extremum B one local minimum but no local maximum C one local maximum but no local minimum D one local minimum and one local maximum
Engineering-Mathematics       Functions       GATE 1993
Question 10 Explanation:
Note: Out of syllabus.
 Question 11

The Laplace transform of the periodic function f(t) described by the curve below, i.e., is _________ A Out of syllabus.
Engineering-Mathematics       Functions       GATE 1993
 Question 12

Let A and B be sets with cardinalities m and n respectively. The number of one-one mappings (injections) from A to B, when m < n, is:

 A mn B nPm C mCn D nCm E mPn
Engineering-Mathematics       Functions       GATE 1993
Question 12 Explanation:
Let,
A = {a1, a2, ... am} and
B = {b1, b2, ... bn}
A one-one function 'f' assigns each element ai of A a distinct element, bj=f(ai) of Bi for a, there are n choices, for a2 there are n-1 choices, for am there are (n-(m-1)) choices.
i.e., Question 13
Consider the following ANSI C function:
int SimpleFunction (int Y[], int n, int x)
{
int total = Y, loopIndex;
for (loopIndex = 1; loopIndex <= n - 1; loopIndex++)
total = x * total + Y[loopIndex]
}
Let Z be an array of 10 elements with Z[i]=1, for all i such that 0 ≤ i ≤ 9. The value returned by SimpleFunction(Z, 10, 2) is _______
 A 1023
Programming       Functions       GATE 2021 CS-Set-1
Question 13 Explanation:
Array Z consists of 10 elements and that element's values are 1.
n=10,x=2
Initial total value is 1 => total=1.
For loop will execute 9 times.
loopindex=1, 1<=9 condition is true then
total = x * total + Y[loopIndex]= 2*1+Y=2+1=3
loopindex=2, 2<=9 condition is true then
total=2*3+Y=6+1=7
loopindex=3, 3<=9 condition is true then
total=2*7+Y=14+1 =15
loopindex=4, 4<=9 condition is true then
total= 2*15+Y=30+1=31
loopindex=5, 5<=9 condition is true then
total=2*31+Y=62+1=63
loopindex=6, 6<=9 condition is true then
total=2*63+Y=126+1=127
loopindex=7, 7<=9 condition is true then
Total =2*127+Y=254+1=255
loopindex=8, 8<=9 condition is true then
total=2*255+Y=510+1=511
loopindex=9, 9<=9 condition is true then
total=2*511+Y=1022+1=1023
loopindex=10, 10<=9 condition is false then
Total value is returned which is 1023.
You can also write generalized formulae 210-1=1023
 Question 14
Study the following program: //precondition: x>=0 public void demo(int x) { System.out.print(x % 10); if (x % 10 != 0) { demo(x/10); } System.out.print(x%10); } Which of the following is printed as a result of the call demo(1234)?
 A 1441 B 3443 C 12344321 D 43211234
Programming       Functions       ISRO-2007
Question 14 Explanation:
demo(1234) ---> First it will print “4” then 4!=10 condition is true again it call demo(123)
demo(123)------> It will print “3” then 3!=10 condition is true again it call demo(12)
demo(12)------> It will print “2” then 2!=10 condition is true again it call demo(1)
demo(1)------> It will print “1” then 1!=10 condition is true again it call demo(0)
It will print again 1,2,3 and 4 as there is another Print statement is in each function call.
 Question 15
What is the output of this C++ program? A 910 B 920 C 870 D 900
Programming-for-Output-Problems       Functions       ISRO-2017 May
Question 15 Explanation:
Step-1: In main function, number variable has been initialized to 30.
Step-2: We pass address of number as parameters in the square function. As per the concept of function overloading in C++ the second square function will be executed.
Step-3: --(*y) will be executed first since decrement operator has the higher precedence than multiplication.
*x = (*x) * --(*y);
*x = 30 * 29;
*x = 870
Note: x is a pointer variable and it holds the address of the variable number.
 Question 16
Consider the following C function A Call swap (a, b) B Call swap (&a, &b) C swap(a, b) cannot be used as it does not return any value D swap(a, b) cannot be used as the parameters passed by value
Programming       Functions       ISRO-2017 May
Question 16 Explanation: Question 17
What is the output of the following program? A 20 10 10 B 20 10 20 C 20 20 20 D 10 10 10
Programming       Functions       ISRO-2017 May
Question 17 Explanation:
Step-1: Every program starts execution from main() function.
Step-2: By default tmp value 20 will print initially.
Step-3: It calls fun() then it will print 10
Step-4: Again we are in main() function and printing value 20. Actually, the static value will return because its scope is a lifetime. But we are given tmp value as global. So, it prints 20 instead of 10.
 Question 18
The cubic polynomial y(x) which takes the following values:
y(0) = 1,
y(1) = 0,
y(2) = 1,
y(3) = 10 is
 A x3 +2 x2 + 1 B x3 + 3x2 + 1 C x3 + 1 D x3 – 2 x2 + 1
Engineering-Mathematics       Functions       ISRO CS 2009
Question 18 Explanation:
Substitute the values of x (0,1,2 and 3) in the options and check which option gives the corresponding y(x) values. The function x3 – 2 x2 + 1 gives the required values.
x = 0: y(x) = 1
x = 1: y(x) = 0
x = 2: y(x) = 8 - 8 + 1 = 1
x = 3: y(x) = 27 - 18 + 1 = 10
 Question 19
Consider the polynomial, p(x) = a0 + a1X + a2X2 + a3X3 where ai ≠ 0, ∀i . The minimum number of multiplications needed to evaluate p on an input X is:
 A 3 B 4 C 6 D 9
Engineering-Mathematics       Functions       ISRO CS 2009
Question 19 Explanation:
P(X)=a0+a1+a2X2+a3X3
=a0+X(a1+X(a2+a3X))
↓ ↓ ↓
③ ② ①
Here, minimum 3 multiplication needed
 Question 20
The shift operator E is defined as E[f(xi)] = f(xi + h) and E'[f(xi)] = f(xi – h) then △ (forward difference) in terms of E is
 A E-1 B E C 1 – E-1 D 1 – E
Engineering-Mathematics       Functions       ISRO CS 2009
Question 20 Explanation: Question 21
A root of equation f(x) = 0 can be computed to any degree of accuracy if a ‘good’ initial approximation x0 is chosen for which
 A f (x0) > 0 B f (x0) f (x0)” > 0 C f (x0) f (x0)” < 0 D f (x0)” > 0
Engineering-Mathematics       Functions       ISRO CS 2009
 Question 22
What is the least value of the function f(x) = 2x2– 8x – 3 in the interval [ 0 , 5] ?
 A -15 B 7 C -11 D -3
Engineering-Mathematics       Functions       ISRO CS 2013
Question 22 Explanation:
One method is trial and error method
Substitute all the value of x from 0 to 5

The value of f(x) is -3 when x=0
The value of f(x) is -9 when x=1
The value of f(x) is -11 when x=2
The value of f(x) is -9 when x=3
The value of f(x) is -3 when x=4

The value of f(x) is -7 when x=5

so the least value is -11
Second method:
→We can solve this one by using derivatives.
→Given function is f(x) = 2x2 -8x -3
→ f'(x)=4x-8 (first derivative)
a f''(x)=4 (Second derivative)
Here we got constant value which means that it has minimal value at the point x=2
So we can find the minimum value by substituting value 2 in place of “x” in the given function.
Minimum value is 2⨉(2)2 -8⨉(2) -3= -11
 Question 23

Given below are three implementations of the swap( ) function in C++ : Which of these would actually swap the contents of the two integer variables p and q ?

 A (a) only B (b) only C (c) only D (b) and (c) only
Programming-in-c++       Functions       UGC-NET CS 2018 JUNE Paper-2
Question 23 Explanation:
Module - (a) is call by value. So, by using that code w can not swap the contents.
Module - (b) is call by reference. So, the modification of content in the function reflects the changes in the main program. Swapping is done in the module - (b).
Module - (c) is passing addresses as parameters but in the functions definition. We are changing the addresses not the content. So, swapping of the values can’t be done.
 Question 24
The keyboard used to transfer control from a function back to the calling function is:
 A Switch B Go to C go back D Retun
Programming       Functions       Nielit Scientist-B IT 4-12-2016
Question 24 Explanation:
● The return statement terminates the execution of a function and it returns the control to the calling function.
● The execution resumes in the calling function at a point immediately following the call.
 Question 25
Consider the following function definition.
void greet (int n)
{
if (n>0)
{
printf("hello");
greet(n-1);
}
printf("world");
}
If you run greet(n) for some non-negative integer n, what would it print?
 A n times “hello”, followed by n + 1 times “world” B n times “hello”, followed by n times “world” C n times “helloworld” D n + 1 times “helloworld” E n times “helloworld”, followed by “world”
Programming       Functions       TIFR PHD CS & SS 2018
 Question 26
Consider the function
int fun(x: integer)
{
If x > 100
then
fun = x – 10;
else
fun = fun(fun(x + 11));
}
For the input x = 95, the function will return
 A 89 B 90 C 91 D 92
Programming       Functions       ISRO DEC 2017 22- Soon
Question 26 Explanation:
Value returned by
fun(95) = fun(fun(106))
= fun(96)
= fun(fun(107))
= fun(97)
= fun(fun(108))
= fun(98)
= fun(fun(109))
= fun(99)
= fun(110)
= fun(100)
= fun(fun(111))
= fun(101)
= 91
 Question 27
Consider the function
int func(int num)
{
int count = 0;
while(num)
{
count++;
num >>= 1;
}
return(count) ;
}
For func(435) the value returned is
 A 9 B 8 C 0 D 10
Programming       Functions       ISRO DEC 2017 22- Soon
Question 27 Explanation:
func (435)
count = 0 Shift right of 1, which means the number gets half.
while (num)
{
Shift left of 1, which means, the number gets doubled.
count++;
num>>=1;
}
return (count); 435/2 = 217/2 = 108/2 = 54/2 = 27/2 = 13/2 = 6/2 = 3/2 = 1/2 = 0
Count: 1, 2, 3, 4, 5, 6, 7, 8, 9. Χ
(or)
(435)10 = (110110011)2
The given program counts total number of bits in binary representation and fails when while (num) becomes all zeroes.
 Question 28
Output of following program?
#include
void dynamic(int s,..)
{
printf("%d",s);
}
int main()
{
dynamic(2,4,6,8);
dynamic(3,6,9);
return 0;
}
 A 23 B compile error C 43 D 32
Programming       Functions       Nielit Scientist-B IT 22-07-2017
Question 28 Explanation:
● The latest compiler giving compilation error ​ “error: expected declaration specifiers or ‘...’ before ‘.’ toke​ n“
● Old compiler may support that syntax, in that syntax only first argument is defined which consists of remainings arguments but not defined.
● For the function call dynamic(2,4,6,8), first argument 2 is printed.
● For the function call dynamic(3,6,9);first argument 3 is printed.
 Question 29
The following program
main()
{
inc();
inc();
inc();
}
inc()
{
static int x;
printf("%d", ++x);
}
 A prints 012 B prints 123 C prints 3 consecutive, but unpredictable numbers D prints 111
Programming-for-Output-Problems       Functions       ISRO CS 2015
Question 29 Explanation:
In this question, we have to remind one point about “static” storage class.
Static storage class by default value is 0.
Step-1: We are calling inc( ) in main function. So, it will enter into inc() function.
Here, we are using pre increment function, so it replaced 0 with 1.
Step-2: Second inc() in main function. So, it will enter into inc() function.
Here, we are using pre increment function, so it replaced 1 with 2.
Step-3: Third inc() in main function. So, it will enter into inc() function.
Here, we are using pre increment function, so it replaced 2 with 3.
Note: The static storage class instructs the compiler to keep a local variable in existence during the life-time of the program instead of creating and destroying it each time it comes into and goes out of scope.
 Question 30

In C language ______ is a process in which a function calls itself repeatedly until some specified condition has been satisfied

 A Infinite loop B Call by value C Call by reference D Recursion
Programming       Functions       JT(IT) 2018 PART-B Computer Science
Question 30 Explanation:
Recursion is a process in which a function calls itself repeatedly until some specified condition has been satisfied.
 Question 31
A member function can always access the data in __________ , (in C++).
 A the class of which it is member B the object of which it is member C the public part of its class D the private part of its class
Programming-in-c++       Functions       UGC NET CS 2017 Nov- paper-2
Question 31 Explanation:
→ A member function can always access the data in the class of which it is member.
→ Functions within classes can access and modify (unless the function is constant) data members without declaring them, because the data members are already declared in the class.
 Question 32
Which of the following is not correct (in C++) ?
 A Class templates and function templates are instantiated in the same way B Class templates differ from function templates in the way they are initiated C Class template is initiated by defining an object using the template argument D Class templates are generally used for storage classes E None of the above
Programming-in-c++       Functions       UGC NET CS 2017 Nov- paper-2
Question 32 Explanation:
(1) TRUE: Class templates and function templates are instantiated in the same way
(2) FALSE: Class templates differ from function templates in the way they are initiated
(3) FALSE: Class template is initiated by defining an object using the template argument
(4)FALSE: Class templates are generally used for storage classes
 Question 33
Which of the following cannot be passed to a function in C++ ?
 A Constant B Structure C Array D Header file
Programming-in-c++       Functions       UGC NET CS 2017 Jan -paper-2
Question 33 Explanation:
→ Header files contain definitions of Functions and Variables, which is imported or used into any C++ program by using the pre-processor #include statement. Header file have an extension ".h" which contains C++ function declaration and macro definition.
→ Header file is a library file, we can not passed to a function in C++.
→ We can pass constant,Structure and Array
 Question 34
If a function is friend of a class, which one of the following is wrong?
 A A function can only be declared a friend by a class itself. B Friend functions are not members of a class, they are associated with it. C Friend functions are members of a class. D It can have access to all members of the class, even private ones.
OOPS       Functions       UGC NET CS 2016 Aug- paper-2
Question 34 Explanation:
→ A friend function of a class is defined outside that class' scope but it has the right to access all private and protected members of the class. Even though the prototypes for friend functions appear in the class definition, friends are not member functions.
TRUE: function can only be declared a friend by a class itself.
TRUE: Friend functions are not members of a class, they are associated with it.
FALSE:Friend functions are members of a class.
TRUE: It can have access to all members of the class, even private ones.
 Question 35
A function template in C++ provides _____ level of generalization.
 A 4 B 3 C 2 D 1
Programming-in-c++       Functions       UGC NET CS 2016 Aug- paper-2
Question 35 Explanation:
→ ​ A function template in C++ provides 2 level of generalization.
→ Templates are a feature of the C++ programming language that allows functions and classes to operate with generic types. This allows a function or class to work on many different data types without being rewritten for each one.
 Question 36
When a method in a subclass has the same name and type signatures as a method in the super class, then the method in the subclass _____ the method in the super class.
 A Overloads B Friendships C Inherits D Overrides
OOPS       Functions       UGC NET CS 2016 July- paper-2
Question 36 Explanation:
→ When a method in a subclass has the same name and type signatures as a method in the superclass, then the method in the subclass overrides the method in the superclass.
 Question 37
A function object :
 A is an instance of a class for which operator ( ) is a member function. B is an instance of a class for which operator → is a member function. C is a pointer to any function D is a member function of a class
Programming-in-c++       Functions       UGC NET CS 2004 Dec-Paper-2
Question 37 Explanation:
A function object is an object to which the function call operator can be applied. Typically, it is a class that defines the function call operator (operator()()) as a member function. When a function object is used as a function, the function call operator is invoked whenever the function is called.
 Question 38
Non modifiable procedures are called
 A Serially useable procedures B Concurrent procedures C Reentrant procedures D Top down procedures
Programming       Functions       UGC NET CS 2004 Dec-Paper-2
Question 38 Explanation:
→ A computer program or subroutine is called reentrant if it can be interrupted in the middle of its execution and then safely be called again ("re-entered") before it’s previous invocation complete execution.
→ The interruption could be caused by an internal action such as a jump or call, or by an external action such as an interrupt or signal. The previous invocations may resume correct execution before the reentered invocation completes, unlike recursion, where the previous invocations may only resume correct execution once the reentered invocation completes.
Rules:
1. Reentrant code may not hold any static or global non-constant data.
2. Reentrant code may not modify itself.
3. Reentrant code may not call non-reentrant computer programs or routines.
 Question 39
Data members and member function of a class by default is respectively :
 A private and public B public C public and private D private
Programming-in-c++       Functions       UGC NET CS 2005 Dec-Paper-2
Question 39 Explanation:
If we do not specify any access modifiers for the members inside the class then by default the access modifier for the members will be Private.
 Question 40
Nonmodifiable procedures are called :
 A Serially usable procedure B Concurrent procedure C Reentrant procedure D Top down procedure
Programming       Functions       UGC NET CS 2005 Dec-Paper-2
Question 40 Explanation:
→ A computer program or subroutine is called reentrant if it can be interrupted in the middle of its execution and then safely be called again ("re-entered") before it’s previous invocation complete execution. → The interruption could be caused by an internal action such as a jump or call, or by an external action such as an interrupt or signal. The previous invocations may resume correct execution before the reentered invocation completes, unlike recursion, where the previous invocations may only resume correct execution once the reentered invocation completes.
Rules:
1. Reentrant code may not hold any static or global non-constant data.
2. Reentrant code may not modify itself.
3. Reentrant code may not call non-reentrant computer programs or routines.
 Question 41
When a function is recursively called, all automatic variables :
 A are initialized during each execution of the function B are retained from the last execution C are maintained in a stack D are ignored
Programming       Functions       UGC NET CS 2006 Dec-paper-2
Question 41 Explanation:
→ When a function is recursively called, all automatic variables are initialized during each execution of the function. → Automatic local variables primarily applies to recursive lexically-scoped languages. An automatic variable is a local variable which is allocated and deallocated automatically when program flow enters and leaves the variable's scope. The scope is the lexical context, particularly the function or block in which a variable is defined.
 Question 42
If we define the functions f, g and h that map R into R by : f(x) = x​ 4​ , g(x) = √ x 2 + 1 , h(x) = x​ 2​ + 72, then the value of the composite functions ho(gof) and (hog)of are given as
 A x​ 8​ – 71 and x​ 8​ – 71 B x​ 8​ – 73 and x​8​ – 73 C x​ 8​ + 71 and x​ 8​ + 71 D x​ 8​ + 73 and x​ 8​ + 73
Engineering-Mathematics       Functions       UGC NET CS 2014 Dec-Paper-2
Question 42 Explanation:
Given f(x) = x​ 4​ , g(x) = √ x 2 + 1 , h(x) = x​ 2​ + 72
for, ho(gof)
gof=g(f(x))
=g(x​ 4​ )
=√(x​ 8​ +1)
ho(gof)=h(gof)
=h(√(x​ 8​ +1))
=(√(x​ 8​ +1)​ 2​ +72
=x​ 8​ +1+72
=x​ 8​ +73
√ x 2 + 1 , h(x) = x​ 2​ + 72
for, (hog)of,
hog=h(g(x))
=h(√(x​ 2​ +1)
=(√(x​ 2​ +1)​ 2​ +72
=x​ 2​ + 1+72
=x​ 2​ +73
(hog)of=(hog)(f(x))
=(hog)(x​ 4​ )
=(x​ 4​ )​ 2​ +73
=x​ 8​ +73
Hence, option-D is the correct answer
 Question 43
When we pass an array as an argument to a function, what actually gets passed ?
 A Address of the array B Values of the elements of the array C Base address of the array D Number of elements of the array
Programming       Functions       UGC NET CS 2014 June-paper-2
Question 43 Explanation:
When we pass an array as an argument to a function it actually gets passed base address of the array.
 Question 44
A friend function can be used to
 A avoid arguments between classes. B allow access to classes whose source code is unavailable. C allow one class to access an unrelated class. D None of the above
Programming-in-c++       Functions       UGC NET CS 2014 June-paper-2
Question 44 Explanation:
A friend function of a class is defined outside that class scope but it has the right to access all private and protected members of the class. Even though the prototypes for friend functions appear in the class definition, friends are not member functions.
→A function can only be declared a friend by a class itself.
→It can have access to all members of the class, even private ones.
→ A friend function can be used to allow one class to access an unrelated class.
 Question 45
Which of the following is the correct value returned to the operating system upon the successful completion of a program ?
 A 0 B 1 C -1 D Program do not return a value.
Programming       Functions       UGC NET CS 2014 June-paper-2
Question 45 Explanation:
The operating system will return 0 when it’s successfully execute a program.
 Question 46
Given below are three implementations of the swap( ) function in C++ : Which of these would actually swap the contents of the two integer variables p and q ?
 A (a) only B (b) only C (c) only D (b) and (c) only
Programming       Functions       UGC NET CS 2018 JUNE Paper-2
Question 46 Explanation:
Module -(a) is call by value , so by using that code w can not swap the contents.
Module -(b) is call by reference , So the modification of content in the function reflects the changes in the main program. Swapping is done in the module -(b).
Module -(c) is passing addresses as parameters but in the functions definition , We are changing the addresses not the content So swapping of the values can’t be done.
 Question 47
Match the following in List - I and List - II, for a function f : A (a)-(i), (b)-(ii), (c)-(iii) B (a)-(iii), (b)-(ii), (c)-(i) C (a)-(ii), (b)-(i), (c)-(iii) D (a)- (ii), (b)-(iii), (c)-(i)
Engineering-Mathematics       Functions       UGC NET CS 2018 JUNE Paper-2
Question 47 Explanation:
● The function is injective (one-to-one) if each element of the codomain is mapped to by at most one element of the domain. An injective function is an injection. Notationally:
∀ x, x ′ ∈ X , f (x) = f (x ′ ) ⇒ x = x ′
Or, equivalently (using logical transposition),
∀ x, x ′ ∈ X , x = / x ′ ⇒ f (x) = / f (x ′ )
● The function is surjective (onto) if each element of the codomain is mapped to by at least one element of the domain. (That is, the image and the codomain of the function are equal.) A surjective function is a surjection. Notationally:
∀ y ∈ Y , ∃x ∈ X such that y = f (x)
A constant function is a ​ function​ whose (output) value is the same for every input value. For example, the function y(x) =4 is a constant function because the value y(x) is 4 regardless of the input value x
 Question 48
_______ is often used to prove the correctness of a recursive function.
 A Diagonalization B Communitivity C Mathematical Induction D Matrix Multiplication
Programming       Functions       UGC NET CS 2013 Dec-paper-2
Question 48 Explanation:
→ Mathematical Induction is often used to prove the correctness of a recursive function.
→ Mathematical Induction is a special way of proving things. It has only 2 steps:
Step-1: Show it is TRUE for the first one
Step-2: Show that if any one is TRUE then the next one is true
Then all are true
 Question 49
Consider the function
find (int x, int y)
{return ((x < y) ? 0 : (x - y)) ; }
Let a, b be two non-negative integers. The call find {a, find(a, b)} can be used to find the
 A maximum of a, b B positive difference of a, b C sum of a, b D minimum of a, b
Programming       Functions       NIELIT Technical Assistant_2016_march
 Question 50
How many constructors can a class have ?
 A zero B 2 C 2 D any number
Programming-in-c++       Functions       UGC NET CS 2008 Dec-Paper-2
Question 50 Explanation:
There is no restriction to to have number of constructors in a lass.
 Question 51
Consider the code below, defining the function mystery: mystery(a,b){ if (a < 0 or b < 0) return 0; else if (a == 0) return b+1; else if (b == 0) return mystery(a-1,1); else return mystery(a-1, mystery(a,b-1)); } (i) Express mystery(1, n) as a function of n. (ii) Express mystery(2, n) as a function of n. (iii) Compute mystery(3, 2) and mystery(3, 3).
 A Descriptive Explanation
Programming       Functions       CHENNAI MATHEMATICAL INSTITUTE (M.Sc. / Ph.D. Programme in Computer Science)15 May 2013
Question 51 Explanation:
(i) mystery(1, n) = n + 2. We prove this by induction on n.
Clearly mystery(1, 0) = mystery(0, 1) = 1 + 1 = 2 = 0 + 2. Assuming that mystery(1, n − 1) = n + 1, mystery(1, n) = mystery(0, mystery(1, n − 1)) = mystery(0, n + 1) = (n + 1) + 1 = n + 2.
(ii) mystery(2, n) = 2n + 3, and we again prove this by induction on n.
Clearly mystery(2, 0) = mystery(1, 1) = 1 + 2 = 3 = 2 · 0 + 3. Assuming that
mystery(2, n−1) = 2(n−1)+3 = 2n+1, mystery(2, n) = mystery(1, mystery(2, n−1)) = mystery(1, 2n + 1) = (2n + 1) + 2 = 2n + 3.
(iii) mystery(3, 0) = mystery(2, 1) = 2 + 3 = 5.
mystery(3, 1) = mystery(2, mystery(3, 0)) = mystery(2, 5) = 2 · 5 + 3 = 13.
mystery(3, 2) = mystery(2, mystery(3, 1)) = mystery(2, 13) = 2 · 13 + 3 = 29.
mystery(3, 3) = mystery(2, mystery(3, 2)) = mystery(2, 29) = 2 · 29 + 3 = 61.
 Question 52
Consider the code below, defining the functions f and g: f(m, n) { if (m == 0) return n; else { q = m div 10; r = m mod 10; return f(q, 10*n + r); } } g(m, n) { if (n == 0) return m; else { q = m div 10; r = m mod 10; return g(f(f(q, 0), r), n-1); } } (a) Compute g(3, 7), g(345, 1), g(345, 4) and g(345, 0). (b) What does g(m, n) compute, for nonnegative numbers m and n? (c) How much time does it take to compute f (m, n) and g(m, n)?
 A Descriptive Explanation
Programming       Functions       CHENNAI MATHEMATICAL INSTITUTE(M.Sc. / Ph.D. Programme in Computer Science) 18May 2015
Question 52 Explanation:
In the following, by “reverse of a number a” we mean the number got by reversing the digits of a.
We first prove by induction on the number of digits in m that the result of f (m, n) is the reverse of m appended to n.
• If m = 0, then f (m, n) = n, as we require.
• If m < 10, then q = 0 and r = m, and a recursive call is made to f (0, 10n + m) = 10n + m, which is the reverse of the digits of m appended to n.
• If m > 10, then r is the last digit of m, and q is all the other digits. There is a recursive call to f (q, 10n + r), whose output (by induction hypothesis applied on q, which has one fewer digit than m) is the reverse of q appended to 10n + r, which is exactly the reverse of m appended to n.
Now f (a, 0) is the reverse of a, and f (f (a, 0), b) is the reverse of reverse of a appended to b, or in other words, a appended to b. Thus g(m, 1) appends to the last digit of m the other digits of m—performing a right rotate of m, in other words. g(m, n) is just n right rotates performed on m.
It follows that g(3, 7) = 3, g(345, 1) = 534 and g(345, 0) = 345.
It is also easy to see from the code that f (m, n) takes O(log m) time and g(m, n) takes O(n · log m) time.
 Question 53
What does the following function compute in terms of n and d, for integer values of d? Note that the operation / denotes floating point division, even if the arguments are both integers. function foo(n,d){ if (d == 0){ return 1; }else{ if (d < 0){ return foo(n,d+1)/n; }else{ return n*foo(n,d-1); }}}
 A log d n if d < 0, n d if d > 0. B n d for all values of d. C n × d if d > 0, n ÷ d if d < 0. D n × d for all values of d.
Programming       Functions       CHENNAI MATHEMATICAL INSTITUTE M.Sc. / Ph.D. Programme in Computer Science (18 May 2017)
Question 53 Explanation:
For d > 0, this computes n d by repeated multiplication. For d negative, the answer is 1/nd by repeated division.
 Question 54
Consider the following functions f() and g(). f(){ w = 5; w = 2*z + 2; } g(){ z = w+1; z = 3*z - w; print(z); } We start with w and z set to 0 and execute f() and g() in parallel—that is, at each step we either execute one statement from f() or one statement from g(). Which of the following is not a possible value printed by g()?
 A -2 B -1 C 2 D 4
Programming       Functions       CHENNAI MATHEMATICAL INSTITUTE M.Sc. / Ph.D. Programme in Computer Science (18 May 2017)
Question 54 Explanation:
The possible values are : {-1,-2,3,4,7,13}, corresponding to the interleavings below. Question 55
Consider the following function that takes as input a sequence A of integers with n elements, A, A, . . . , A[n] and an integer k and returns an integer value. The function length(S) returns the length of sequence S. Comments start with //. function mystery(A, k){ n = length(A); if (k > n) return A[n]; v = A; AL = [ A[j] : 1 <= j <= n, A[j] < v ]; // AL has elements < v in A Av = [ A[j] : 1 <= j <= n, A[j] == v ]; // Av has elements = v in A AR = [ A[j] : 1 <= j <= n, A[j] > v ]; // AR has elements > v in A if (length(AL) >= k) return mystery(AL,k); if (length(AL) + length(Av) >= k) return v; return mystery(AR, k - (length(AL) + length(Av))); } (a) Explain what the function computes. (b) What is the worst-case complexity of this algorithm in terms of the length of the input sequence A? (c) Give an example of a worst-case input for this algorithm.
 A Descriptive Explanation
Programming       Functions       CHENNAI MATHEMATICAL INSTITUTE M.Sc. / Ph.D. Programme in Computer Science (18 May 2017)
Question 55 Explanation:
(a) mystery(A, k) finds the kth element in A in ascending order. This is a divide-and- conquer selection algorithm, similar to quicksort.
(b) The worst case complexity is O(n 2 ) because of the fixed choice of pivot, as in quicksort.
(c) A typical worst case input would be, for instance, where A is in ascending order and k = n.
 Question 56
In the code fragment to the right, start and end are integer values and prime(x) is a function that returns true if x is a prime number and false otherwise. At the end of the loop: i := 0; j := 0; k := 0; for (m := start; m <= end; m := m+1){ if (prime(m)){ i := i + m; k := k - m; }else{ j := j - m; k := k + m; } }
 A k == i-j. B k == j-i. C k == -j-i. D Depends on start and end.
Programming       Functions       CHENNAI MATHEMATICAL INSTITUTE M.Sc. / Ph.D. Programme in Computer Science (18 May 2016)
Question 56 Explanation:
The value of i + j + k is 0 initially, and also at the end of each iteration of the loop. Thus k = −j − i at the end of the loop.
 Question 57
Consider the function M defined as follows: (a) Compute the following. i. M (101) ii. M (99) iii. M (87) (b) Give a constant-time algorithm that computes M (n) on input n. (A constant- time algorithm is one whose running time is independent of the input n.)
 A Explanation
Programming       Functions       CHENNAI MATHEMATICAL INSTITUTE M.Sc. / Ph.D. Programme in Computer Science (18 May 2016)
Question 57 Explanation:
(a) M (101) = M (99) = M (87) = 91
(b) The following is a simple algorithm for computing M . It just compares n with 100, and either subtracts 10 from n or returns a constant, all of which are constant- time operations.
if (n> 100) return (n-10) else return 91
To prove that the algorithm is correct, we need to show that M (n) = 91 for n < 101. Notice first that M (101) = 91. From the following claim, it follows that M (n) = 91 for all n ≤ 100
Claim: For all k ≥ 1 and all n such that 101 − 11k ≤ n < 101 − 11(k − 1), M (n) = 91.
The proof of the claim is by induction on k.
Suppose k = 1 and 90 ≤ n < 101.
M (n)
= M (M (n + 11))
= M (n + 11 − 10) ( since n + 11 ≥ 101)
= M (n + 1)
Therefore, M (90) = M (91) = · · · = M (100) = M (101) = 91.
Assume the claim holds for k ≤ m. Consider n such that 101 − 11k ≤ n < 101 − 11(k − 1) for k = m + 1.
M (n) = M (M (n + 11))
= M (91) (M (n + 11) = 91, by IH )
= 91 by base case
Thus the claim holds for all k, and hence M (n) = 91 for all n < 101.
 Question 58
What are the possible values of gcd(7p + 94, 7p 2 + 97p + 47), where p is an arbitrary integer?
 A Either 1 or 94 B Either 94 or 47 C Either 1 or 47 D None of these
Programming       Functions       CHENNAI MATHEMATICAL INSTITUTE - M.Sc. / Ph.D. Programme in Computer Science ( 15 May 2014 )
Question 58 Explanation:
Use Euclid’s algorithm for gcd.
 Question 59
Consider the code below, defining the function A: A(m, n, p) { if (p == 0) return m+n; else if (n == 0 && p == 1) return 0; else if (n == 0 && p == 2) return 1; else if (n == 0) return m; else return A(m, A(m,n-1,p), p-1); } (a) Express A(m, n, 1) as a function of m and n. (b) Express A(m, n, 2) as a function of m and n. (c) Compute A(2, 2, 3) and A(2, 3, 3).
 A Explanation
Programming       Functions       CHENNAI MATHEMATICAL INSTITUTE - M.Sc. / Ph.D. Programme in Computer Science ( 15 May 2014 )
Question 59 Explanation:
(a) Evaluating A(m, n, 1) for small values of n suggests that A(m, n, 1) = mn. We verify it using induction. The base case is clear: A(m, 0, 1) = 0 = m · 0. For the induction step, assuming that A(m, n − 1, 1) = m(n − 1), we have
A(m, n, 1) = A(m, A(m, n − 1, 1), 0) = A(m, m(n − 1), 0) = m + m(n − 1) = mn.
(b) Evaluating A(m, n, 2) for small values of n suggests that A(m, n, 2) = m n . We verify it using induction. The base case is clear: A(m, 0, 2) = 1 = m 0 . For the induction step, assuming that A(m, n − 1, 2) = m n−1 , we have
A(m, n, 2) = A(m, A(m, n − 1, 2), 1) = A(m, m n−1 , 1) = m · m n−1 = m n.
(c) A(2, 0, 3) = 2.
A(2, 1, 3) = A(2, A(2, 0, 3), 2) = A(2, 2, 2) = 2 2 = 4. A(2, 2, 3) = A(2, A(2, 1, 3), 2) = A(2, 4, 2) = 2 4 = 16. A(2, 3, 3) = A(2, A(2, 2, 3), 2) = A(2, 16, 2) = 2 16 = 65536.
 Question 60
Consider the following C++ function f() :
unsigned int f(unsigned int n)
{
unsigned int b=0;
while(n)
{
b+=n&1;
n>>=1;
}
return b;
}
The function f() returns the int that represents the___p___in the binary representation of positive integer n, where P is
 A number of 0's B number of bits C number of consecutive 1's D number of 1's
Programming-in-c++       Functions       UGC NET June-2019 CS Paper-2
Question 60 Explanation:
& operator does the binary and operation of both value and 1
when b += n & 1 is given
n and 1, both will be converted to binary and binary & operation is calculated
any number & 000000001
it will only compare the last bit of both numbers, if both right most bit is 1 then the value is incremented by 1 and the number n is right shifted that means it loses the value of right most bit and again new right most bit is binary anded with 1.
So the value is nothing but the number of 1's of the binary format of number.
 Question 61
Consider the following recursive C function that takes two arguments
unsigned int rer ( unsigned int n, unsigned int r){
If (n > 0) return ( n%r + rer (n/r,r));
else return 0;
}
What is the return value of the function rer when it is called as rer (513, 2 )?
 A 9 B 8 C 5 D 2
Programming       Functions       ISRO CS 2020       Video-Explanation
Question 61 Explanation:
Given input function is rer(513, 2)
Condition: n>0 Sum of bits=2 if they given 513. It represented in binary.
 Question 62
In the following procedure
Integer procedure P(X,Y);
Integer X,Y;
value x;
Begin
K=5;
L=8
P=x+y;
End
X is called by value and Y is called by name. If the procedure were invoked by the following program fragment
K=0
L=0
Z=P(K,L);
then the value Z would be set equal to
 A 5 B 8 C 13 D 0
Programming       Functions       ISRO CS 2020       Video-Explanation
 Question 63

The time complexity of the following C function is (assume n>0)

```int recursive (int n)
{
if (n==1) return(1);
else return(recursive (n-1) + recursive(n-1));
}```
 A O(n) B O(n log n) C O(n2) D O(2n)
Programming       Functions       APPSC-2016-DL-CA
Question 63 Explanation:
T(n) = 2T(n-1)+a is the recurrence equation found from the code given.
Note ‘a’ is a constant O(1) cost that the non-recursive part of the function takes.
Solving the recurrence by Back Substitution:
T(n) = 2T(n-1)+a
T(n-1) = 2T(n-2)+a
T(n-2) = 2T(n-3)+a
:
:
Thus we can write the equation as follows
T(n) = 2(2T(n-2)+a)+a = 4T(n-2) + 2a + a
T(n) = 4(2T(n-3)+a) + 2a + a = 8T(n-3) + 4a + 2a + a
:
:
:
T(n) = 2k T(n-k) + (2k - 1)a
On substituting limiting condition,
T(1) = 1
=> n - k = 1
=> k = n-1
Therefore, our solution becomes
2n-1 + (2n-1 - 1)a
= O(2n)
 Question 64
```int function (int x, int y)
{
if(y<=0) return x;
return function (y, x%y);
} ```

The above recursive function computes ______

 A GCD of X and Y B xy C yx D HCF of x and y E Both A and D
Programming       Functions       CIL 2020
Question 64 Explanation:
Let’s take x=3, y=5 Question 65
Code blocks allow many algorithms to be implemented with the following parameters :
 A clarity, elegance, performance B clarity, elegance, efficiency C elegance, performance, execution D execution, clarity, performance
Programming       Functions       UGC NET CS 2014 June-paper-3
Question 65 Explanation:
Algorithm to be implemented should be:
Clear: Clear means it should convey the exact work you are trying to accomplish.
 Question 66

Consider the following statements S1, S2 and S3 :

S1 : In call-by-value, anything that is passed into a function call is unchanged in the caller’s scope when the function returns.

S2 : In call-by-reference, a function receives implicit reference to a variable used as argument.

S3 : In call-by-reference, caller is unable to see the modified variable used as argument.
 A S3 and S2 are true. B S3 and S1 are true. C S2 and S1 are true. D S1, S2, S3 are true.
Programming       Functions       UGC NET CS 2014 Dec - paper-3
 Question 67
Given the following pseudocode for function printx() below, how many times is x printed if we execute printx(5)?
void printx(int n) { if (n==0) {
printf("x");
}
for (int i=0;i<=n-1;++i){ printx(n-1);
}
}
 A 625 B 256 C 120 D 24 E 5
Programming       Functions       TIFR PHD CS & SS 2019
 Question 68
Consider the following recursive function mc91.
int mc91(int n)
{
print n
if (n > 100) { return n - 10;
}
else {
return mc91(mc91(n+11));
}
}
Let
Out = {n : there is an x ∈ {0, 1, . . . , 100} such that n is one of the integers printed by mc91(x)}.
Then, which of the following is Out?
 A {n : −∞ < n ≤ 100} B {n : 0 ≤ n ≤ 101} C {n : 0 ≤ n ≤ 110} D {n : 0 ≤ n ≤ 111} E {n : 0 ≤ n < +∞}
Programming       Functions       TIFR PHD CS & SS 2016
 Question 69
Consider the following code fragment in the C programming language when run on a non-negative integer n.
int f(int n)
{
if(n==0 || n==1) return 1;
else
return f(n-1) + f(n-2);
}
Assuming a typical implementation of the language, what is the running time of this algorithm and how does it compare to the optimal running time for this problem?
 A This algorithm runs in polynomial time in n but the optimal running time is exponential in n. B This algorithm runs in exponential time in n and the optimal running time is exponential in n. C This algorithm runs in exponential time in n but the optimal running time is polynomial in n. D This algorithm runs in polynomial time in n and the optimal running time is polynomial in n. E The algorithm does not terminate
Programming Programming       Functions       TIFR PHD CS & SS 2015
 Question 70

What is the output of the following program:

int main()

{

int a, i, b=16;

for(i=0; i<5; i++)

a[i]=2*i;

f(a,b);

for(i=0; i<5; i++)

printf(“%d”,a[i]);

printf(“%d”, b);

}

f(int *x, int y)

{

int i;

for(i=0; i<5; i++)

*(x+i)+=2;

y+=2;

}
 A 4,6,8,10,12,16 B 2,4,6,8,10,26 C 2,4,6,8,10,18 D 2,4,6,8,10,16
Programming       Functions       HCU PHD CS 2018 December
Question 70 Explanation: Now in statement 4, function f will be called.
Now in the function f every array element is increased by 2, now the new elements in the array will be, But the value of ‘b’ will not get affected, since its address is not passed.
Now the output printed will be,
2, 4, 6, 8, 10, 16
 Question 71

In the following C language function, Iet n ≥ m. How many recursive calls are made by this function ?

int gcd(n,n)

{

if(n%m ==0) return m;

n=n%n;

return gcd(n,n)

}
 A O(log2 n) B O(n) C O(√n) D O(log2 log2n)
Programming       Functions       HCU PHD CS MAY 2016
Question 71 Explanation:
If we consider worst case then it will be option a ... as an example take n=11 m=8 .. it will be O(logn)
 Question 72

What is the value of F(4) using the following procedure?

function F(k: integer) : integer;

begin

if (k<3) then F:=k

else F := F(k-1)*f(k-2)+F(k-3);

end;
 A 5 B 6 C 7 D 8
Programming       Functions       HCU PHD CS MAY 2014
Question 72 Explanation: Question 73

Which of the following is valid return value for a function fn in 'C' which is declared as

void fn(int, char *);
 A NULL B 0 C -1 D None of the above
Programming       Functions       HCU PHD CS MAY 2013
Question 73 Explanation:
Void functions are created and used just like value-returning functions except they do not return a value after the function executes.
 Question 74
In C, which of the following variables are created at the time of a function call and destroyed when the function returns?
 A integer variables B parameters to the function C static variables declared within the function D extern variables
Programming       Functions       HCU PHD CS MAY 2013
Question 74 Explanation:
Function parameters have local scope. This means that they are created when the function is invoked, and are destroyed when the function block terminates.
 Question 75
Consider the following recursive Java function f that takes two long arguments and returns a float value: Which of the following real values best approximates the value of f(1,3)?
 A 0.2 B 0.4 C 0.6 D 0.8
Programming       Functions       UGC NET JRF November 2020 Paper-2
There are 75 questions to complete.