Font size
WorksheetsWOMANIA PRELIMS
Total questions: 25
Worksheet time: 13mins
What will be the output of the following code snippet?
#include <stdio.h>
void solve() {
int a[] = {1, 2, 3, 4, 5};
int sum = 0;
for(int i = 0; i < 5; i++) {
if(i % 2 == 0) {
sum += *(a + i);
}
else {
sum -= *(a + i);
}
}
printf("%d", sum);
}
int main() {
solve();
return 0;
}
2
15
Syntax error
3
What is the disadvantage of arrays in C?
The amount of memory to be allocated should be known beforehand.
Elements of an array can be accessed in constant time.
Elements are stored in contiguous memory blocks.
Multiple other data structures can be implemented using arrays.
What will be the output of the following code snippet?
#include <stdio.h>
void solve() {
int a = 3;
int res = a++ + ++a + a++ + ++a;
printf("%d", res);
}
int main() {
solve();
return 0;
}
12
25
20
18
If p is an integer pointer with a value 1000, then what will the value of p + 5 be?
1020
1005
1004
1010
What will be the result of the following code snippet?
#include <stdio.h>
void solve() {
char ch[10] = "abcdefghij";
int ans = 0;
for(int i = 0; i < 10; i++) {
ans += (ch[i] - 'a');
}
printf("%d", ans);
}
int main() {
solve();
return 0;
}
45
36
20
100
Which of the following is not a storage class specifier in C?
Volatile
Extern
typedef
Static
What kind of linked list is best to answer questions like “What is the item at position n?”
Singly linked list
Doubly linked list
Circular linked list
Array implementation of linked list
Which of the following does the balancing symbols algorithm include?
balancing double quotes
balancing single quotes
balancing operators and brackets
balancing parentheses, brackets and braces
Consider the graph shown below.
Which of the following edges form the MST of the given graph using Prim’a algorithm, starting from vertex 4.
(4-3)(5-3)(2-3)(1-2)
(4-3)(3-5)(5-1)(1-2)
(4-3)(3-5)(5-2)(1-5)
(4-3)(3-2)(2-1)(1-5)
What will be the output of the following code?
#include<bits/stdc++.h>
using namespace std;
void func(char* str2, char* str1)
{
int m = strlen(str2);
int n = strlen(str1);
for (int i = 0; i <= n - m; i++)
{
int j;
for (j = 0; j < m; j++)
if (str1[i + j] != str2[j])
break;
if (j == m)
cout << i << endl;
}
}
int main()
{
char str1[] = "1253234";
char str2[] = "323";
func(str2, str1);
return 0;
}
1
2
3
4
What is the average case time complexity of merge sort?
O(n log n)
O(n2)
O(n2 log n)
O(n log n2)
Euclid’s algorithm is used for finding ___________
GCD of two numbers
GCD of more than three numbers
LCM of two numbers
LCM of more than two numbers
Banker's algorithm is used
To prevent deadlock
To deadlock recovery
To solve the deadlock
None of these
The size of virtual memory is based on which of the following?
CPU
RAM
Address bus
Data bus
Which of the following is a condition that causes deadlock?
Mutual exclusion
Hold and wait
Circular wait
No preemption
All of these
In the network HTTP resources are located by
uniform resource identifier
unique resource locator
unique resource identifier
union resource locator
The microprocessor of a computer can operate on any information if it is present in ______________ only.
Program counter
Flag
Main Memory
Secondary Memory
Which of the following is not true about the address bus?
It consists of control PIN 21 to 28
It is a bidirectional bus
It is 16 bits in length
Lower address bus lines (AD0 – AD7) are called “Line number”
Which of the following is the most commonly used data structure for implementing Dijkstra’s Algorithm?
Max priority queue
Stack
Circular queue
Min priority queue
What is the time complexity of Dijikstra’s algorithm?
O(N)
O(N²)
O(N³)
O(log N)
In a timeshare operating system, when the time slot assigned to a process is completed, the process switches from the current state to?
Suspended state
Terminated state
Ready state
Blocked state
Each vowel of the word ADJECTIVE is substituted with the next letter of the English alphabetical series, and each consonant is substituted with the letter preceding it. How many vowels are present in the new arrangement?
None
One
Two
Three
In cryptography, what is cipher?
algorithm for performing encryption and decryption
encrypted message
both algorithm for performing encryption and decryption and encrypted message
decrypted message
Shift cipher is also referred to as
Caesar cipher
Cipher
Shift cipher
Cipher text
A guy was writing his first book. After saving the document, he locked his laptop with a password and mentioned some phrases for the hint box.
A friend of his tried opening his laptop but found out that it was password protected. Following is the hint that appeared.
1 mobile 3 books 2 roars 1 night 4 balls 2 lighters 1 ghost 1 hat 3 watches
It seemed awkward to him. Can you help him in cracking the password?
(a)
