adplus-dvertising
51. 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
Discuss
Answer: (c).Base address of the array

52. While (87) printf("computer");

The above C statement will
a. print "computer" 87 times
b. print "computer" 0 times
c. print "computer" 1 times
d. print "computer" infinite times
Discuss
Answer: (d).print "computer" infinite times

53. 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
Discuss
Answer: (c).allow one class to access an unrelated class

54. What is the size of the following Union ? Assume that the size of int = 2, size of float = 4, size of char = 1

union tag {
int a;
float b;
char c;
};
a. 2
b. 4
c. 1
d. 7
Discuss
Answer: (b).4

55. What is the output of the following program segment?

sum(n)
{
if ( n < 1 ) return n;
else return (n + sum(n–1));
}
main()
{
printf(“%d”, sum(5));
}
a. 10
b. 16
c. 15
d. 14
Discuss
Answer: (c).15

56. Assume that x and y are non-zero positive integers. What does the following program segment perform?

while (x!=0)
{
if (x>y)
x = x-y
else
y=y-x;
printf(“%d”,x);
a. Computes LCM of two numbers
b. Computes GCD of two numbers
c. Divides large number with small number
d. Subtracts smaller number from large number
Discuss
Answer: (b).Computes GCD of two numbers

57. Consider the following program segment:

d=0;
for(i=1; i<31, ++i)
for(j=1; j<31, ++j)
for(k=1; k<31, ++k)
if ((i+j+k)%3)= = 0);
d = d + 1;
printf(“%d”, d);

The output will be
a. 9000
b. 3000
c. 90
d. None of the above
Discuss
Answer: (d).None of the above

58. Consider the following two function declarations :

(i) int *f( )
(ii) int (*f)( )

Which of the following is true ?
a. Both are identical.
b. The first is a correct declaration and the second is wrong.
c. Both are different ways of declaring pointer to a function.
d. The first declaration is a function returning a pointer to an integer and the second is a pointer to function returning integer.
Discuss
Answer: (d).The first declaration is a function returning a pointer to an integer and the second is a pointer to function returning integer.

59. Assume that we have constructor function for both Base and Derived classes. Now consider the declaration :

main ( )
Base *p = new Derived;

In what sequence, the constructor will be executed ?
a. Derived class constructor is followed by Base class constructor
b. Base class constructor is followed by Derived class constructor
c. Base class constructor is never called
d. Derived class constructor is never called
Discuss
Answer: (b).Base class constructor is followed by Derived class constructor

60. What is the output of the following program ?

#include< stdio.h >
main( )
{
int a, b = 0;
static int c[10] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 0};
for (a=0; a<10;++a);
if ((c[a]%2)= =0) b+=c[a];
printf(“%d”,b);
}
a. 15
b. 25
c. 45
d. 20
Discuss
Answer: (d).20

Page 6 of 16