Sunteți pe pagina 1din 25

Q.No.1 A.

Hello
What will be the output of the program? B.Hi Hello
#include<stdio.h> C.No output
int i;
D.Infinite loop
int fun();

int main()
{
while(i)
{
fun();
A
main();
1 }
printf("Hello\n");
return 0;
}
int fun()
{
printf("Hi");
}

Q.No.2 A.128 characters


The maximum combined length of the B.256 characters
command-line arguments including the spaces C.67 characters
D.It may vary from one operating system to D
between adjacent arguments is
another
Q.No.1 A.Error: invalid assignment for x
Point out the compile time error in the program B.Error: suspicious pointer conversion
given below. C.No error
2 #include<stdio.h> D.None of above

int main() C
{
int *x;
*x=100;
return 0;
}
Q.No.2 Which of the following statements A.float **fun(float***);
correctly declare a function that receives a B.float *fun(float**);
pointer to pointer to a pointer to a float and C.float fun(float***);
returns a pointer to a pointer to a pointer to a D.float ****fun(float***); D
pointer to a float?

3 Q.No.1 A.remove(var-name);
How will you free the allocated memory? B.free(var-name);
C.delete(var-name); B
D.dalloc(var-name);

Q.No.2 A.All of them let you define new values


What is the similarity between a structure, B.All of them let you define new data types
union and enumeration? C.All of them let you define new pointers B
D.All of them let you define new structures

Q.No.1 a) public
4
b) private D
Which of these following members are not c) protected
accessed by using direct member access
operator? d) Both a & b

Q.No.2 a) 1
b) 2
How many objects can present in a single c) 3 D
class? d) as many as possible

5 Q.No.1 a) void
What is the return type of the conversion b) int
operator? c) float D
d) no return type

Q.No.2 a) 3 B
What is the output of this program? b) 4
#include <iostream> c) 5
using namespace std; d) None of the mentioned
class sample
{
public:
sample(int i) : m_i(i) { }
public:
int operator()(int i = 0) const
{
return m_i + i;
}
operator int () const
{
return m_i;
}
private:
int m_i;
friend int g(const sample&);
};
int f(char c)
{
return c;
}
int main()
{
sample f(2);
. cout << f(2);
return 0;
}

Q.No.1
Pick out the correct statement. a) Increment operator ++ adds 1 to its
6
operand
b) Increment operator ++ adds 2 to its
operand
A
c) Decrement operator ++ subtracts 1 to its
operand
d) None of the mentioned
Q.No.2 a) A derived class’s constructor cannot B
explicitly invokes its base class’s
Pick out the correct statement constructor.
b) A derived class’s destructor cannot
invoke its base class’s destructor.
c) A derived class’s destructor can invoke
its base class’s destructor.
d) None of the mentioned

Q.No.1 a) Deriving a class from one direct base


Pick out the correct statement about multiple class
inheritance. b) Deriving a class from more than one
direct base class B
7 c) Deriving a class from more than one
direct derived class
d) None of the mentioned

Q.No.2. How many types of inheritance are a) 2


there in c++? b) 3
c) 4 D
d) 5

Q.No.1 a) Creating a function without having to


8 What is a function template? specify the exact type.
b) Creating a function with having a exact
type.
c) both a & b
d) none of the mentioned A

Q.No.2 a) You only need to write one function, and


it will work with many different types.
Pick out the correct statement. b) it will take a long time to execute A
c) duplicate code is increased
d) none of the mentioned
Q.No.1 a) Used to hold the type information
What is meant by type_info? returned by the typeid operator
9 b) Used to hold the type information
returned by the dynamic_cast
A
c) Used to hold the type information
returned by the static cast
d) None of the mentioned

Q.No.2. At which time does the static_cast can be a) Compile-time construct


applied? b) Runtime construct
c) Both a & b A
d) None of the mentioned

Q.No.1 a. Top-in-first-out
b One-end-first-out
Stack is a an ordered collection of items c Last-in-first-out C
10 forming a list that is

Q.No.2 a Stable
The nature of collection of data items in a b Unstable
stack is c Dynamic C

11 Q.No.1 a. Deque
To represent hierarchical relationship between b. Priority
elements, which data structure is suitable? c. Tree
d. All of above C

Q.No.2 a. One-dimensional array and a counter B


b One-dimensional array and two counter
A queue is implemented, without the
involvement of movement of elements, by c One-dimensional array viewed as a circle

12 Q.No.1 A
At any point of time, the number of elements a rear - front + 1
in the queue is given by b rear - front
c rear-1

Q.No.2. Initially setting rear -1 and the counter a . rear = front


front to zero, the condition that queue is empty b. rear < front
is given by c . rear = front = 0
B

Q.No.1 a. Dn = n log2n
b. Dn = n log2n+1
c. Dn = log2n D
The depth of a complete binary tree is given
d. Dn = log2n+1
by
Q.No.2 A binary tree can easily be converted into a. by replacing each empty sub tree by
13 q 2-tree a new internal node

b. by inserting an internal nodes for non-


empty node
D
c. by inserting an external nodes for non-
empty node

d. by replacing each empty sub tree by a


new external node
14 Q.No.1
When converting binary tree into extended a. internal nodes on extended tree
binary tree, all the original nodes in binary tree b. external nodes on extended tree A
are c. vanished on extended tree
d. None of above
Q.No.2 a. ABFCDE
b. ADBFEC
The post order traversal of a binary tree is c. ABDECF C
DEBFCA. Find out the pre order traversal
d. ABDCEF

15 Q.No.1
In a graph if e=[u, v], Then u and v are called a. endpoints of e D
b. adjacent nodes
c. neighbors
d. all of above
Q.No.2 a. a tree graph
b. free tree
A connected graph T without any cycles is c. a tree D
called
d. All of above

Q.No.1 a. u is adjacent to v but v is not adjacent to


u
In a graph if e=(u, v) means b. e begins at u and ends at v D
16 c. u is processor and v is successor
d. both b and c

Q.No.2 a. isolated
If every node u in G is adjacent to every other b. complete
node v in G, A graph is said to be c. finite B
d. strongly connected
17 Q.No.1 a. FAEKCDBHG
When in order traversing a tree resulted E A C b. FAEKCDHGB B
K F H D B G; the preorder traversal would c. EAFKHDCBG
return d. FEAKDCHBG

Q.No.2 The time factor when determining the


efficiency of algorithm is measured by a. Counting microseconds
b. Counting the number of key operations B
c. Counting the number of statements
d. Counting the kilobytes of algorithm
18 Q.No.1
The complexity of merge sort algorithm is a. O(n)
b. O(log n)
c. O(n2) D
d. O(n log n)
Q.No.2
a. O(n)
The complexity of Bubble sort algorithm is b. O(log n) C
c. O(n2)
d. O(n log n)

19 Q.No.1 a. Sorting
b. Merging
The operation of processing each element in c. Inserting D
the list is known as
d. Traversal

Q.No.2 a. for relatively permanent collections of A


data
Arrays are best data structures b. for the size of the structure and the data
in the structure are constantly changing
c. for both of above situation
d. for none of above situation

Q.No.1 a. by this way computer can keep track only


the address of the first element and the
The elements of an array are stored addresses of other elements can be
20
successively in memory cells because calculated
A
b. the architecture of computer memory
does not allow arrays to store other than
serially
c. both of above
d. none of above

Q.No.2 a. Arrays
b. Records
Which of the following data structure can't c. Pointers A
store the non-homogeneous data elements?
d. None

21 Q.No.1 A. Error: in int(*p)() = fun; B


Point out the error in the following B. Error: fun() prototype not defined
program. C. No error
#include<stdio.h> D. None of these
int main()
{
int (*p)() = fun;
(*p)();
return 0;
}
int fun()
{
printf("know-it.com\n");
return 0;
}

Q.No.2 A. 'c' means argument control 'v' means


What do the 'c' and 'v' in argv stands for? argument vector
B. 'c' means argument count 'v' means
argument vertex
C. 'c' means argument count 'v' means C
argument vector
D. 'c' means argument configuration 'v'
means argument visibility

22 Q.No.1
What will be the output of the program? C
#include<stdio.h> A. 2 4
36
#include<stdarg.h>
B.
void dumplist(int, ...);
248
3, 6, 9, 7
int main()
C.
{
48
dumplist(2, 4, 8);
697
dumplist(3, 6, 9, 7);
D.
return 0;
111
}
1111
void dumplist(int n, ...)
{
va_list p; int i;
va_start(p, n);

while(n-->0)
{
i = va_arg(p, int);
printf("%d", i);
}
va_end(p);
printf("\n");
}

Q.No.2 A. x is a pointer
What is x in the following program? B. x is an array of three pointer
#include<stdio.h> C. x is an array of three function pointers
D. Error in x declaration
int main()
{ C
typedef char (*(*arrfptr[3])())[10];
arrfptr x;
return 0;
}

23 Q.No.1 A. *pt='';
Which statement will you add to the B. pt='\0';
following program to ensure that the C. pt='\n';
D
program outputs D. *pt='\0';
"CDAC" on execution?
#include<stdio.h>

int main()
{
char s[] = "CDAC";
char t[25];
char *ps, *pt;
ps = s;
pt = t;
while(*ps)
*pt++ = *ps++;

/* Add a statement here */


printf("%s\n", t);
return 0;
}

Q.No.2 A. Mello A
What will be the output of the B. Hello
program ? C. HMello
#include<stdio.h> D. MHello

int main()
{
char str[20] = "Hello";
char *const p=str;
*p='M';
printf("%s\n", str);
return 0;
}

Q.No.1 In C, if you pass an array as an A. Value of elements in array


24
argument to a function, what actually B. First element of the array
gets passed? C. Base address of the array C
D. Address of the last element of array

Q.No.2 A. 5
What will be the output of the program ? B. 4
#include<stdio.h> C. 6
int main() D. 7
{
float arr[] = {12.4, 2.3, 4.5, 6.7};
B
printf("%d\n", sizeof(arr)/sizeof(arr

[0]));
return 0;
}

25 Q.No.1 A. 10
What will be the output of the B. 20
program ? C. 30 B
#include<stdio.h> D. 0

int main()
{
union var
{
int a, b;
};
union var v;
v.a=10;
v.b=20;
printf("%d\n", v.a);
return 0;
}

Q.No.2 A.-1, 0, 1, 2, 3, 4
What will be the output of the program ? B. -1, 2, 6, 3, 4, 5
#include<stdio.h> C. -1, 0, 6, 2, 3, 4
int main(){ D. -1, 0, 6, 7, 8, 9
enum days {MON=-1, TUE, WED=6, THU,
FRI,
SAT}; D
printf("%d, %d, %d, %d, %d, %d\n", MON,
TUE, WED, THU, FRI, SAT);
return 0;
}

26 Q.No.1 A. 12, 12, 12


What will be the output of the B. 112, 1, 12
program ? C.32, 1, 12 A
#include<stdio.h> D. -64, 1, 12
int main()
{
int i=4, j=8;
printf("%d, %d, %d\n", i|j&j|i, i|j&j|i,

i^j);
return 0;
}
Q.No.2 A. 2, 2 A
What will be the output of the program B. 8, 8
in 16- C. 5, 5
D. 4, 4
bit platform (under DOS)?
#include<stdio.h>

int main()
{
struct node
{
int data;
struct node *link;
};
struct node *p, *q;
p = (struct node *) malloc(sizeof(struct

node));
q = (struct node *) malloc(sizeof(struct
node));
printf("%d, %d\n", sizeof(p), sizeof(q));
return 0;
}

27 Q.No.1 a) 10 A
b) 11
What is the output of this program? c) 20
#include <iostream> d) 22
using namespace std;
class number
{
int i;
public:
int geti();
void puti(int j);
};
int number::geti()
{
return i;
}
void number::puti(int j)
{
i = j;
}
int main()
{
number s;
s.puti(10);
cout << s.geti( );
return 0;
}

Q.No.2 a) Enter an integer 5 C


What is the output of this program? Variable entered is 5
#include <iostream> b) runtime error
using namespace std; c) error
class sample d) none of the mentioned
{
private:
int var;
public:
void input()
{
cout << var;
}
void output()
{
cout << "Variable entered

is ";
cout << var << "\n";
}
};
int main()
{
sample object;
object.input();
object.output();
object.var();
return 0;
}

28 Q.No.1 When we are using heap operations a) rename the objects


what do we need to do to save the memory? b) delete the objects after processing
c) both a & b B
d) None of the mentioned

Q.No.2 Which function in c++ will take large a) string


objects? b) class
c) vector C
d) None of the mentioned

Q.No.1Pick out the correct syntax of operator a) operator float()const


29
conversion. b) operator float()
c) operator const A
d) None of the mentioned

Q.No.2. How to declare the complex number? a) (3,4)


b) complex(3,4)
c) (3,4i) B
d) None of the mentioned

30 Q.No.1. Which of the following is not a a) real D


function of complex values? b) imag
c) norm
d) Cartesian

Q.No.2. Which of the following permits a) type


function overloading on c++? b) number of arguments
c) both of the mentioned C
d) none of the mentioned

Q.No.1 a) 3 4
What is the output of this program? b) 4 3
#include <iostream> c) 4
using namespace std; d) 3
class BaseClass
{
protected:
int i;
public:
31 BaseClass(int x)
{
i = x; B
}
~BaseClass()
{
}
};
class DerivedClass: public

BaseClass
{
int j;
public:
DerivedClass(int x, int y):

BaseClass(y)
{
j = x;
}
~DerivedClass()
{
}
void show()
{
cout << i << " " << j <<

endl;
}
};
int main()
{
DerivedClass ob(3, 4);
ob.show();
return 0;
}

Q.No.2. Which constructor will initialize the a) derived class


base class data member? b) base class
c) class B
d) None of the mentioned
32 Q.No.1. Which class is used to design the a) abstract class
base class? b) derived class A
c) base class
d) None of the mentioned

Q.No.2 Which is also called as abstract class? a) virtual function


b) pure virtual function
c) derived class B
d) None of the mentioned

Q.No.1. What is meant by containership? a) class contains objects of other class


types as its members
33
b) class contains objects of other class
types as its objects A
c) both a & b
d) none of the mentioned

Q.No.2 a) constructor and destructor


What does derived class does not b) friends
inherit from the base class? c) operator = () members D
d) all of the mentioned

34 Q.No.1 What can be passed by non- a) int


type template parameters during b) float C
compile time? c) constant expression
d) none of the mentioned

Q.No.2 a) regular non-templated C++ class C


From where does the template class derived? b) templated class
c) a or b
d) none of the mentioned

35 Q.No.1 a ABCD**+
The postfix form of the expression b AB*CD+* B
(A*B)*(C+D) is c AB*CD*+

Q.No.2 a (a + 1) * b – b
a*b can be defined recursively as b (a – 1) * b + b B
c (b + 1) * a – b

Q.No.1 Deletion of an element from a a Increase in the front counter


36
queue causes b Decrease in the front counter
c Decrease in the rear counter A

Q.No.2 The ambiguity of a queue being full or a Extra element


empty encountered by the usage of circular b Extra array position C
queue is overcome by the introduction of c Boolean variable

37 Q.No.1 An algorithm that calls itself a. Sub algorithm


directly or indirectly is known as b. Recursion B
c. Polish notation
d. Traversal algorithm

Q.No.2 The in order traversal of tree will yield a. Binary trees


a sorted listing of elements of tree in b. Binary search trees
c. Heaps B
d. None of above
Q.No.1 a. LOC(Array[5]=Base(Array)+w(5-
The memory address of fifth element of lower bound), where w is the number
an array can be calculated by the of words per memory cell
formula for the array

b. LOC(Array[5])=Base(Array[5])+(5-
38 lower bound), where w is the number
of words per memory cell for the A
array
c. LOC(Array[5])=Base(Array[4])+(5-
Upper bound), where w is the
number of words per memory cell for
the array

d. None of above

Q.No.2. Which of the following data structures a. linear arrays


are indexed structures? b. linked lists
c. both of above A
d. none of above

39 Q.No.1 The space factor when determining a. Counting the maximum memory needed A
the efficiency of algorithm is measured by by the
algorithm
b. Counting the minimum memory needed
by the algorithm
c. Counting the average memory needed by
the algorithm
d. Counting the maximum disk space
needed bythe algorithm

Q.No.2.The Worst case occur in linear search a. Item is somewhere in the middle of the
algorithm when array
b. Item is not in the array at all
c. Item is the last element in the array D
d. Item is the last element in the array or is
not there at all

Q.No.1 Arrays are best data structures a. for relatively permanent collections of
40 data
b. for the size of the structure and the data A
in the structure are constantly changing
c. for both of above situation
d. for none of above situation
Q.No.2 a. by this way computer can keep track
The elements of an array are stored only the address of the first element and
successively in memory cells because the addresses of other elements can be
calculated
b. the architecture of computer memory
does not allow arrays to store other than A
serially
c. both of above
d. none of above

S-ar putea să vă placă și