You are on page 1of 22

Question Bank

Subject Code:BCA309
CO Distribution Analysis At A Glance
C.O. Type C.O. Total In-Percentage
CO1 33 16.84
CO2 40 20.41
CO3 32 16.33
CO4 36 18.37
CO5 32 16.33
CO6 23 11.73

Marks wise total no of CO Distribution, Total No of Question: 196


C.O. Type Marks:2 Marks:5 Marks:10
CO1 32 1 0
CO2 20 10 10
CO3 2 20 10
CO4 4 22 10
CO5 2 20 10
CO6 1 12 10

Page 1 of 22
© Q.Bank:BCA309, Printed by:sacharya, Date & Time:13-11-23 12:16:50
Modul
Sl.No. Question Marks CO BL
e
1 Define ADT with suitable example. 2 1 CO1 BL1
(i) A full binary tree with n leaves contains: a) n b)
log2n c) 2n-1 d) 2n nodes.

2 (ii) Given a Binary search tree, which of the following 2 4 CO1 BL1
traversals would print the values of the nodes in sorted
order? a) Preorder b) Postorder c) Inorder d) None of
the above.
3 Define a B-Tree with a suitable example. 2 4 CO1 BL1
4 Define a Stack with a suitable example. 2 3 CO1 BL1
5 Explain how do you test for an empty stack. 2 3 CO2 BL2
What do you meant by fully parenthesized expression?
6 2 3 CO2 BL2
Give a example.
What are the postfix and prefix forms of the expression
7 2 3 CO2 BL2
A+B*(C-D)/(P-R)?
8 What are the advantages of Python? 2 1 CO1 BL1
9 Explain Python Functions and Packages? 2 1 CO1 BL1
How to overload constructors or methods in Python
10 2 1 CO1 BL1
with example.
What is the expected time required to search for a
value in a Binary Search Tree containing n nodes?
11 2 4 CO2 BL2
Explain it with a reasonable assumption about the
structure of the tree.
What is the difference between remove() function and
12 2 1 CO2 BL2
del statement?
Explain swapcase() function in the Python with proper
13 2 1 CO1 BL1
example.
14 Why do we use join() function in Python? 2 1 CO1 BL1
Is Python a compiled language or an interpreted
15 2 1 CO2 BL2
language? Explain.
16 Explain what do you mean by slicing in python. 2 1 CO1 BL1
17 What is lambda function in Python? 2 1 CO1 BL1
18 How can you generate random numbers in Python? 2 1 CO1 BL1
What will the following snippet of code print?
(i)
myint = 10

def myfunction():

myint = 20
19 myfunction() 2 1 CO2 BL2
print(myint)
(ii)
my_list = [7, 9, 8, 2, 5, 0, 1, 3, 6]

my_list.pop(2)

print(my_list)

Page 2 of 22
© Q.Bank:BCA309, Printed by:sacharya, Date & Time:13-11-23 12:16:50
What are the advantages of Binary search over Linear
20 2 5 CO2 BL2
search?
Write the drawbacks of array implementation of
21 2 3 CO2 BL2
Queue?
Write the steps involved in the insertion and deletion of
22 2 3 CO2 BL2
an element in a stack.
Write the stack overflow and underflow condition. List
23 the area of applications where stack data structure can 2 3 CO2 BL2
be used?
What is a Stack? Which data structure is used to
24 2 3 CO2 BL2
perform recursion?
25 Describe the types of Data Structures. 2 3 CO1 BL1
Are Stack and Queue the same thing? If not, explain
26 2 3 CO1 BL1
why.
What are three different ways of fetching every third
27 2 3 CO1 BL1
item in a List?
What is the default return type of malloc()? Why do we
28 2 3 CO1 BL1
need to typecasting?
How can a polynomial such as 6x6 + 4x2 – 2x + 10 be
29 2 3 CO2 BL2
represented by a linked list?
30 Why is hashing referred as a heuristic search method? 2 5 CO2 BL2
What is the primary advantage of hashing over
31 2 5 CO2 BL2
deterministic search algorithms?
32 What is a Max Heap? 2 5 CO1 BL1
Evaluate the following postfix expression:
33 2 3 CO2 BL2
4, 5, 4, 2, ^, +, *, 2, 2, ^, 9, 3, /, *,-

Page 3 of 22
© Q.Bank:BCA309, Printed by:sacharya, Date & Time:13-11-23 12:16:50
Predict the behavior of the following codes:
(i)

List = list("String")

print(List)
(ii)

a = True

b = False

c = False
34 if not a or b: 2 2 CO2 BL2

print(1)

elif not a or not b and c:

print(2)

elif not a or b or not b and a:

print(3)

else:

print(4)
35 What are the features of stacks? 2 3 CO1 BL1
List out the different linear and non-linear data
36 2 3 CO1 BL1
structures.
Mention with examples different library functions for
37 2 2 CO1 BL1
List manipulation in Python.
What are the postfix and prefix forms of the expression
38 2 3 CO2 BL2
(a + b) * (c + d) / f?
What is a recursive function? Explain with suitable
39 2 2 CO1 BL1
example.
What are the advantages in the array implementation
40 2 3 CO1 BL1
of list?
41 Differentiate arrays and linked lists. 2 3 CO1 BL1
Binary search cannot be performed on a linked list.
42 5 3 CO3 BL3
Examine.
List out the areas in which data structures are applied
43 2 1 CO1 BL1
extensively.
What are the postfix and prefix forms of the expression
44 2 3 CO1 BL1
(((a / b) - c) + (d * e)) - (a * c)?
45 Give some applications of stack. 2 3 CO1 BL1
46 Define circular linked list with example? 2 3 CO1 BL1
47 Differentiate between data types and data structures. 5 1 CO2 BL2
48 Define Graph and its components. 2 4 CO2 BL2
49 Describe the two types of Graphs with examples. 2 4 CO2 BL2
50 What is a complete binary tree? Give an example. 2 4 CO1 BL1

Page 4 of 22
© Q.Bank:BCA309, Printed by:sacharya, Date & Time:13-11-23 12:16:50
51 Compare complete binary tree and full binary tree. 5 4 CO2 BL2
Write the code for swapping two values
52 2 1 CO1 BL1
programmatically.
53 Define double ended queue. 2 3 CO1 BL1
54 How is the queue implemented by linked list? 5 3 CO2 BL2
Predict the behavior of the following codes:
(i)
for i in (2,3,4):
print("i")
(ii)
x=1234
while x%10:
x=x//10
print(x)
55 (iii) 5 1 CO3 BL3
x=2
y=6
x = x + y/2 + y//4
print(x)
(iv)
z = set('abc$de')
print('a' in z)
(v)
for i in range(1,11):
print("%d"%i)
56 Compare singly linked list with circular linked list. 5 3 CO5 BL5
Distinguish between linear and nonlinear data
57 10 2 CO2 BL2
structures with detailed examples.
What is time complexity? List out the time complexities
58 10 2 CO2 BL2
of different sorting algorithms.
What is space complexity? How is it different from time
59 complexity? What is the space complexity of a list of n 10 2 CO2 BL2
elements?
Evaluate how the Merge Sort would work on an integer
60 5 5 CO5 BL5
list of [6, 5, 3, 1, 8, 7, 2, 4]. Show all the iterations.
Evaluate how the Bubble Sort would work on an
61 integer list of [6, 5, 3, 1, 8, 7, 2, 4]. Show all the 5 5 CO5 BL5
iterations.
Evaluate how the Selection Sort would work on an
62 integer list of [6, 5, 3, 1, 8, 7, 2, 4]. Show all the 5 5 CO5 BL5
iterations.
Evaluate how the Insertion Sort would work on an
63 integer list of [6, 5, 3, 1, 8, 7, 2, 4]. Show all the 5 5 CO5 BL5
iterations.
Evaluate how the Quick Sort would work on an integer
64 5 5 CO5 BL5
list of [6, 5, 3, 1, 8, 7, 2, 4]. Show all the iterations.
Given a list of integers “nums” that is sorted in
ascending order, and an integer “target”, recognize and
65 provide the suitable function to search "target" in nums. 10 5 CO3 BL3
If the "target" exists, then return its index. Otherwise,
return -1.
Page 5 of 22
© Q.Bank:BCA309, Printed by:sacharya, Date & Time:13-11-23 12:16:50
Solve the following programmatically:

66 (i) to find the Factorial of a user given number. 10 1 CO3 BL3

(ii) to print the Fibonacci series up to N-th term.


Design a program to calculate factorial of a user-given
67 5 1 CO6 BL6
number by using the concept of Recursion.
Analyze the behavior of the following code snippets:
(i)
def addItem(listParam):
listParam += [1]
mylist = [1, 2, 3, 4]
addItem(mylist)
print(len(mylist))
(ii)
class tester:
def __init__(self, id):
self.id = str(id)
id = "224"
temp = tester(12)
print(temp.id)
(iii)
i=0
68 while i < 5: 5 1 CO4 BL4
print(i)
i += 1
if i == 3:
break
else:
print(0)
(iv)
def f(x, l = []):
for i in range(x):
l.append(i * i)
print(l)
f(2)
f(3, [3, 2, 1])
f(3)
(v)
List = list("String")
print(List)
Define Hashing. Discuss any one collision Handling
69 10 5 CO5 BL5
Technique with example.
Mention with examples different library functions for
70 10 3 CO2 BL2
List manipulation in Python.
Design two functions for Singly linked list to:

71 (i) insert a node at first 10 3 CO6 BL6

(ii) delete the last node


Design two functions for Doubly linked list to:

72 (i) insert a node at last 10 3 CO6 BL6

(ii) delete the first node

Page 6 of 22
© Q.Bank:BCA309, Printed by:sacharya, Date & Time:13-11-23 12:16:50
Write a script to insert a node at the nth position in a
73 10 3 CO6 BL6
Doubly linked list.
Print the following:
(i) (ii)

* 1

** 23

74 *** 456 10 1 CO3 BL3


**** 7 8 9 10

. .

. .

nth term nth term


Check whether a user-given integer is palindrome or
75 5 1 CO3 BL3
not using a program.
76 Show the ways in which list ADT can be implemented. 5 3 CO3 BL3
Analyze and write a find routine in array
77 5 3 CO4 BL4
implementation.
Analyze and write the array representation of a
78 5 3 CO4 BL4
polynomial: p(x) = 4x3 + 6x2 + 7x + 9
Should arrays or linked lists be used for the following
types of applications? Support your justification.
79 5 3 CO5 BL5
(i) Many search operations in sorted list.

(ii) Many search operations in Unsorted list.


Develop an algorithm for insertion operation in a singly
80 5 3 CO6 BL6
linked list.
Describe the following:

81 (i) Applications of lists. 10 3 CO2 BL2

(ii) Polynomial manipulation.


Develop a program to add the values of the nodes of a
82 10 3 CO6 BL6
linked list and then calculate the mean.
Develop an algorithm for inserting a new element into
83 5 3 CO6 BL6
the stack.
What are priority queues? What are the ways to
84 5 3 CO2 BL2
implement priority queue?
Given the prefix for an expression. Write its postfix:
85 5 3 CO2 BL2
-*-+abc/ef-g/hi
Convert this infix expression to postfix first then
86 evaluate it with the help of Stack: 5 3 CO2 BL2
5 * (6 + 2) - 12 / 4
Circular queue is better than standard linear queue.
87 5 3 CO2 BL2
Why?

Page 7 of 22
© Q.Bank:BCA309, Printed by:sacharya, Date & Time:13-11-23 12:16:50
For railway reservation the queue data structure is
88 5 3 CO5 BL5
preferred —Justify.
Analyze and write a function to check whether a queue
89 5 3 CO4 BL4
is full or empty.
Describe with examples how to evaluate arithmetic
90 10 3 CO2 BL2
expressions using stacks.
Give an algorithm for the push and pop operations on
91 5 3 CO2 BL2
stack using a linked list.
Write the function to examine whether the stack is full
92 5 3 CO3 BL3
or empty.
If the depth of the binary tree is k, the maximum
93 5 4 CO5 BL5
number of nodes in the binary tree is 2k-1. Justify.
For the given binary search tree, if we remove the root
and replace it with something from the left subtree,
what will be the value of the new root? Justify your
answer.

94 5 4 CO5 BL5

95 Define a fully binary tree. Give an example. 5 4 CO3 BL3

Page 8 of 22
© Q.Bank:BCA309, Printed by:sacharya, Date & Time:13-11-23 12:16:50
Discuss with respect to following tree:

(i) List the siblings for node E.

(ii) List the cousins for node G.

(iii) Compute the height.

96 5 4 CO3 BL3

Number the following binary tree to traverse it in

(i) Preorder

(ii) Inorder

(iii) Postorder

(iv) Level Order

97 10 4 CO2 BL2

Discuss Binary Search with an example. Explain why


98 10 5 CO4 BL4
binary search cannot be performed on a linked list.
99 How do you calculate the depth of a B-Tree? 5 5 CO4 BL4

Page 9 of 22
© Q.Bank:BCA309, Printed by:sacharya, Date & Time:13-11-23 12:16:50
List out the properties of B-Tree and B+Tree with
100 10 4 CO2 BL2
proper examples.
101 Analyze the properties of binary heap. 5 4 CO4 BL4
Define a heap and show how it can be used to
102 5 4 CO4 BL4
represent a priority queue.
Write an algorithm for preorder, inorder and postorder
103 10 4 CO4 BL4
traversal of a binary tree.
Explain the following operations on a binary search
tree with suitable algorithms:

104 (i) Find a node 10 4 CO4 BL4

(ii) Find the minimum and maximum elements of


binary search tree
Describe an iterative algorithm to traverse a tree in
105 5 4 CO3 BL3
preorder.
Discuss in detail the various methods in which a binary
106 tree can be represented. Discuss the advantage and 10 4 CO3 BL3
disadvantage of each method.
Explain the B+Tree and its properties with at least
107 10 4 CO5 BL5
two suitable examples.
Construct B-Tree of order 3 to insert the following keys
108 5, 2, 13, 3, 45, 72, 4, 6, 9, 22. Also draw a B-Tree of 10 4 CO3 BL3
order 4 for the same keys.
Explain the properties of AVL tree with examples.
109 Discuss how to insert an element in a AVL tree with an 10 4 CO3 BL3
example.
Explain how deletion can take place in AVL trees with
110 5 4 CO4 BL4
suitable example and algorithms.
What are AVL trees? What are its properties? Describe
111 the different rotations defined for AVL tree with 10 4 CO4 BL4
examples.
Insert the following elements step by step in sequence
into two empty AVL trees
112 10 4 CO6 BL6
(i) 15, 18, 20, 21, 28, 2330, 26

(ii) I, J, K, C, B, F, D, G
Discuss the different traversal techniques in binary tree
113 10 4 CO5 BL5
with suitable algorithms and examples.
Explain the construction of expression tree with
114 5 4 CO4 BL4
example.
115 Give the applications of trees. 5 4 CO4 BL4
Show the result of inserting 15, 17, 6, 19, 11, 10, 13,
116 20, 8, 14, 12 one at a time into an initially empty binary 10 4 CO3 BL3
min heap.
Show the result of performing three delete min
117 5 4 CO3 BL3
operations in the final binary min heap obtained.
Illustrate how delete operation is performed on binary
118 5 4 CO3 BL3
heap.

Page 10 22
© Q.Bank:BCA309, Printed by:sacharya, Date & Time:13-11-23 12:16:50 of
Consider the binary search tree given below.

(i) Find the result of in-order, pre-order, and post-order


traversals.

(ii) Show the deletion of the root node.

(iii) Insert 11, 22, 33, 44, 55, 66, and 77 in the tree

119 10 4 CO5 BL5

(i) Compare B-trees with B+trees.

(ii) Create a B+ tree of order 5 for the following data


120 10 4 CO5 BL5
arriving in sequence:

90, 27, 7, 9, 18, 21, 3, 4, 16, 11, 21, 72


(i) Draw B–Tree of order m = 5 for the keys {K, O, S, V,
M, F, B, G, T, U, W}.

121 (ii) Delete the keys K and G in order. 10 4 CO4 BL4

(iii) Justify the number of splits needed for insertions /


deletions with proper reasons.
Construct AVL trees for the following after rotation:

122 10 4 CO4 BL4

123 What is a graph and its types? Explain with example. 5 4 CO5 BL5
124 Compare directed graph and undirected graph. 5 4 CO5 BL5
125 Compare weighted graph and unweighted graph. 5 4 CO5 BL5

Page 11 22
© Q.Bank:BCA309, Printed by:sacharya, Date & Time:13-11-23 12:16:50 of
Consider the graph given below. Create the adjacency
matrix and adjacency list for it.

126 10 4 CO6 BL6

Find out the in-degree and out-degree of each node in


the given graph.

127 5 4 CO3 BL3

128 Create a complete undirected graph having five nodes. 5 4 CO6 BL6

Page 12 22
© Q.Bank:BCA309, Printed by:sacharya, Date & Time:13-11-23 12:16:50 of
Given the following adjacency matrix, draw the graph
for it.

129 5 4 CO6 BL6

Given the following graph, write the adjacency


matrix for it.

130 5 4 CO6 BL6

Consider the following specification of a graph G:

V(G) = {4, 3, 2, 1}

131 E(G) = {(2, 1), (3, 1), (3, 3), (4, 3), (1,4)} 5 4 CO6 BL6

(i) Draw the undirected graph.

(ii) Draw its adjacency matrix.

Page 13 22
© Q.Bank:BCA309, Printed by:sacharya, Date & Time:13-11-23 12:16:50 of
Consider the weighted graph given below. Create the
adjacency matrix for it.

132 5 4 CO6 BL6

133 Give the purpose of Dijikstra’s algorithm. 5 4 CO5 BL5


134 Differentiate cyclic and acyclic graph. 5 4 CO4 BL4
Classify strongly connected and weakly connected
135 5 4 CO3 BL3
graph.
Define the length and diameter of the graph with help
136 5 4 CO5 BL5
of an example.
137 Define minimum spanning tree. Give an example. 5 4 CO4 BL4
State the principle of counting sort with suitable
138 5 5 CO4 BL4
example.
139 Explain the procedure for Depth First Search algorithm. 5 5 CO4 BL4
Prove that the number of edges in a complete graph of
140 5 5 CO4 BL4
n vertices is n(n-1)/2.
In a complete graph with n vertices, show that the
141 5 5 CO4 BL4
number of spanning trees is at least 2n-1-1.
142 Give some applications of graphs. 5 4 CO3 BL3
Describe in detail about the following representations
of a graph with example:
143 5 4 CO3 BL3
(i) Adjacency Matrix

(ii) Adjacency List


Differentiate depth-first search and breadth-first search
144 5 4 CO3 BL3
traversal of a binary tree with suitable examples.
Compare any two applications of Graph and describe
145 10 4 CO4 BL4
them with your own examples.
Describe any one of the shortest path algorithms with
146 10 5 CO5 BL5
suitable example.
Page 14 22
© Q.Bank:BCA309, Printed by:sacharya, Date & Time:13-11-23 12:16:50 of
Discuss the Prim’s algorithm for minimum spanning
147 10 5 CO5 BL5
tree. Give an example.
Construct a binary tree where the inorder and preorder
traversals of its nodes are given as follows:
148 10 4 CO6 BL6
Inorder: 10, 15, 17, 18, 20, 25, 30, 35, 38, 40, 50

Preorder: 20, 15, 10, 18, 17, 30, 25, 40, 35, 38, 50
What is the precondition of performing binary search in
149 5 5 CO6 BL6
an array? Write the Binary Search algorithm.
Write a program to implement the Merge Sort on an
150 10 5 CO6 BL6
user-given array.
Write a program to implement the Quick Sorton an
151 10 5 CO6 BL6
user-given array.
Write the programs to implement the following on an
user-given array:
152 10 5 CO6 BL6
(i) Selection Sort

(ii) Bubble Sort


Show the result of inserting the keys F, S, Q, K, C, L,
153 H, T, V, W, M, R, N, P, A, B, X, Y, D, Z, E in the order 10 4 CO4 BL4
to an empty B-Tree of degree-3.
Write the different cases to delete a node from a Binary
154 10 4 CO5 BL5
Search Tree. Justify your answer with examples.
Explain the advantages of binary search over
155 5 5 CO5 BL5
sequential / linear search.
Write a function to insert an element in the middle of a
156 5 5 CO6 BL6
singly linked list.

Page 15 22
© Q.Bank:BCA309, Printed by:sacharya, Date & Time:13-11-23 12:16:50 of
If a filesystem has a block size of 4096 bytes, this
means that a file comprised of only one byte will still
use 4096 bytes of storage. A file made up of 4097
bytes will use 4096*2=8192 bytes of storage. Knowing
this, can you fill in the gaps in the calculate_storage
function below, which calculates the total number of
bytes needed to store a file of a given size?

def calculate_storage(filesize):

block_size = 4096

# Use floor division to calculate how many blocks


are fully occupied

full_blocks = ___________

# Use the modulo operator to check whether there's


any remainder

partial_block_remainder = _______________
157 10 1 CO3 BL3
# Depending on whether there's a remainder or not,
return

# the total number of bytes required to allocate


enough blocks

# to store your data.

if partial_block_remainder > 0:

return ___________

return ________
print(calculate_storage(1))

print(calculate_storage(4096))

print(calculate_storage(4097))

print(calculate_storage(6000))

Also write the output of the print statements.


Construct a binary tree where the inorder and
postorder traversals of its nodes are given as follows:

158 Inorder: B, D, A, I, G, E, H, C, F 10 4 CO3 BL3


Postorder: D, B, I, G, H, E, F, C, A

Find the preorder traversal.


Select the best sorting method out of the following -
159 insertion sort, quick sort and merge sort and give 10 4 CO5 BL5
justification.
160 Write a difference between list and tuples. 5 4 CO5 BL5
Page 16 22
© Q.Bank:BCA309, Printed by:sacharya, Date & Time:13-11-23 12:16:50 of
Can you explain the working of Selection Sort
161 5 5 CO5 BL5
algorithm?
162 Develop a simple algorithm for linear search. 5 5 CO3 BL3
(i) Sort the sequence 3, 1, 4, 1, 5, 9, 2, 6, 5 using
163 Insertion sort. 10 5 CO4 BL4
(ii) Describe the routine for insertion sort.
What are the rules for a local and global variable?
164 5 1 CO5 BL5
Explain wih suitable examples.
What is the usage of enumerate() function in Python?
165 Give the output of this example: A[3], A[-3] if 5 1 CO5 BL5
A=[1,4,6,7,9,66,4,94].
Compare AVL Tree and B-Tree with suitable
166 5 1 CO4 BL4
examples.
167 What is a circular queue? What are its advantages? 5 1 CO4 BL4
168 What are the rules of the Tower of Hanoi? 5 1 CO4 BL4
Write the recursive function to find the fibonacci series
169 5 1 CO3 BL3
up till nth term.
Write the functions to implement the following tasks on
a user-given list of integers:
170 10 3 CO3 BL3
(i) Find the frequency of each element.

(ii) Remove the duplicate elements.


Armstrong number is a number that is equal to the sum
of cubes of its digits. For example 0, 1, 153, 370, 371
and 407 are the Armstrong numbers.

153 = (1*1*1)+(5*5*5)+(3*3*3)

where:

(1*1*1)=1
171 10 3 CO4 BL4
(5*5*5)=125

(3*3*3)=27

So:

1+125+27=153

Write a program to check for Armstrong number.


The number will be unique if it is positive integer and
there are no repeated digits in the number. In other
words, a number is said to be unique if and only if the
digits are not duplicate. For example, 20, 56, 9863,
172 145, etc. are the unique numbers while 33, 121, 900, 10 1 CO5 BL5
1010, etc. are not unique numbers.

Write a program to check whether the number is


unique or not.

Page 17 22
© Q.Bank:BCA309, Printed by:sacharya, Date & Time:13-11-23 12:16:50 of
Write a program to print the following pattern:

121

12321

1234321
173 5 1 CO4 BL4
123454321

1234321

12321

121

1
Write a program to print the following pattern:

1 1
174 5 1 CO3 BL3
1 2 1

1 3 3 1

1 4 6 4 1
If the sum of the factorial of digits of a number is equal
to the number itself, the number is called a special
number.

N = 145

Sum = 1! + 4! + 5!
175 5 1 CO3 BL3
= 1 + (4*3*2*1) + (5*4*3*2*1)

= 1 + 24 + 120

= 145 (N)

Write the program to check for Special number.


Write a program to check for a palindromic string.
176 5 1 CO3 BL3
Example: madam.
Is C programming language compiled or interpreted?
177 2 1 CO1 BL1
Why?
What are the Operators in C? Give examples for the
178 5 1 CO1 BL1
different types of operators.
Design a C program to check whether a given number
179 is a three-digit number or not. If it does have three 5 1 CO6 BL6
digits, then find the sum of the digits.
What is the difference between the local and global
180 2 1 CO3 BL3
variables in C? Give suitable examples.
Page 18 22
© Q.Bank:BCA309, Printed by:sacharya, Date & Time:13-11-23 12:16:50 of
Predict the output of this program.

#include <stdio.h>

int main() {

int x = 15, y = 20;


181 2 1 CO4 BL4
int z = x-- - --y;

printf("%d", z);

return 0;

}
Predict the output of this program.

#include <stdio.h>

int main() {

int a = 7, b;
182 2 1 CO4 BL4
b = ++a + a-- - --a;

printf("%d", b);

return 0;

}
Change the following do-while loop into a for loop. Also
rewrite the code by changing the do-while into a while
loop.
int num;

printf(" Enter any number. Enter 999 to stop : ");

scanf("%d", &num);
183 2 2 CO3 BL3
do{

printf("%d", x);

printf(" Enter any number. Enter 999 to stop : ");

scanf("%d", &num);

}while(num != 999);
184 Explain sparse matrix. 2 3 CO5 BL5
What do you mean by Dangling Pointer Variable in C
185 2 3 CO5 BL5
Programming?
186 What is data structure 2 2 CO1 BL1

Page 19 22
© Q.Bank:BCA309, Printed by:sacharya, Date & Time:13-11-23 12:16:50 of
Find the results of the following C codes:
(a) #include <stdio.h>
int main()
{
int d, a = 1, b = 2;
d = a++ + ++b;
printf("%d, %d, %d", d, a, b);
return 0;
}
(b) #include <stdio.h>
int main()
187 { 5 1 CO4 BL4
int d, a = 1, b = 2;
d = ++a +++b;
printf("%d %d %d", d, a, b);
return 0;
}
(c) #include<stdio.h>
int main()
{
int a=0;
a = printf("4");
printf("%d",a);
return 0;
}
(a) What will occur if an array is not initialized, Explain.

(b) There are two types of int-type array data. The first
188 one has 50 elements, while the second one has 30. 5 1 CO6 BL6
Can we transfer a 50-element array to a 30-element
array? Defend it.
189 Give the node structure of a doubly linked list. 2 3 CO6 BL6
190 What is the basic purpose of header of the linked list? 2 3 CO4 BL4
Which sorting algorithm is best if the list is already
191 2 3 CO4 BL4
sorted? Why?
Draw the queue structures in each case when the
following operations are performed on an empty
queue.

(a) Add A, B, C, D, E, F

(b) Delete two letters


192 5 2 CO2 BL2
(c) Add G

(d) Add H

(e) Delete four letters

(f) Add I

Page 20 22
© Q.Bank:BCA309, Printed by:sacharya, Date & Time:13-11-23 12:16:50 of
"Predict the outputs of the following (there are no
errors):
(a)
#include<stdio.h>
void main() {
int color = 2;
switch(color) {
case 0: printf("Black");
case 1: printf("Blue");
case 2: printf("Green");
case 3: printf("Aqua");
default: printf("Other");
}
}
(b)
#include <stdio.h>
void main() {
char arr[]={ 'A', 'B', 'c', 'd', 'E', 'f' };
int size = sizeof(arr) / sizeof(arr[0]);
printf("%d ", size);
}
(c)
193 #include <stdio.h> 5 1 CO4 BL4
void main() {
float f1 = 0.1;
if (f1 == 0.1)
printf("equal ");
else
printf("not equal ");
}
(d)
#include <stdio.h>
#include <string.h>
void main() {
char a[] = "%d ";
printf(a, 85);
}
(e)
#include <stdio.h>
void main() {
int a= -1, b = -a;
int x,y;
x = (a> 0) && (b < 0) || (a< 0) && (b > 0);
y = (a<= 0) || (b >= 0) && (a>= 0) || (b <= 0);
printf("%d ",x == y);
}
Write a program which performs the following tasks:

- Initialize an integer array of 10 elements in main()

- Pass the entire array to a function modify()


194 5 1 CO2 BL2
- In modify() multiply each element of array by 3

- Return the control to main() and print the new array


elements in main()
Write a program to calculate XA + YB, where A and B
195 are n-sized user-given square matrices and X = 2 and 10 1 CO2 BL2
Y = 3.

Page 21 22
© Q.Bank:BCA309, Printed by:sacharya, Date & Time:13-11-23 12:16:50 of
Consider an array A to be an n x n square matrix. The
value n is defined as a constant. You need to write a
program which will do the following:
196 (a) Find the number of non-zero elements in A. 10 1 CO2 BL2

(b) Find the sum of the elements above the diagonal.

(c) Find the product of the diagonal elements.

Page 22 22
© Q.Bank:BCA309, Printed by:sacharya, Date & Time:13-11-23 12:16:50 of

You might also like