
Code2Duo

Quiz
•
Information Technology (IT)
•
University
•
Hard
Svethaa Lingeshwaran
FREE Resource
15 questions
Show all answers
1.
MULTIPLE CHOICE QUESTION
1 min • 1 pt
#include <stdlib.h>
int main()
{
int *pInt;
int **ppInt1;
int **ppInt2;
pInt = (int*)malloc(sizeof(int));
ppInt1 = (int**)malloc(10*sizeof(int*));
ppInt2 = (int**)malloc(10*sizeof(int*));
free(pInt);
free(ppInt1);
free(*ppInt2);
return 0;
}
Choose the correct statement with respect to above C program.
malloc() for ppInt1 and ppInt2 isn’t correct. It’ll give compile time error.
free(*ppInt2) is not correct. It’ll give compile time error
C) free(*ppInt2) is not correct. It’ll give run time error.
) No issue with any of the malloc() and free() i.e. no compile/run time error.
2.
MULTIPLE CHOICE QUESTION
1 min • 1 pt
What is the output of the following program :
print('{0:.2}'.format(1.0 / 3))
0.333333
0.33
0.333333:-2
Error
3.
MULTIPLE CHOICE QUESTION
1 min • 1 pt
What is the output of the following code?
print(tuple[1:3] if tuple == ( 'abcd', 786 , 2.23, 'john', 70.2 ) else tuple())
( \'abcd\', 786 , 2.23, \'john\', 70.2 )
abcd
(786, 2.23)
None of the above
4.
MULTIPLE CHOICE QUESTION
1 min • 1 pt
Postorder traversal of a given binary search tree, T produces the following sequence of keys 10, 9, 23, 22, 27, 25, 15, 50, 95, 60, 40, 29 Which one of the following sequences of keys can be the result of an in-order traversal of the tree T?
9, 10, 15, 22, 23, 25, 27, 29, 40, 50, 60, 95
9, 10, 15, 22, 40, 50, 60, 95, 23, 25, 27, 29
29, 15, 9, 10, 25, 22, 23, 27, 40, 60, 50, 95
A) 95, 50, 60, 40, 27, 23, 22, 25, 10, 9, 15, 29
5.
MULTIPLE CHOICE QUESTION
1 min • 1 pt
Consider the following program that attempts to locate an element x in a sorted array a[ ] using binary search. Assume N>1. The program is erroneous. Under what conditions does the program fail?
def find(a, n, x):
i = 0
j = n
while i < j:
k = (i + j) // 2
if a[k] < x:
i = k + 1
else:
j = k
if i < len(a) and a[i] == x:
print("x is in the array")
else:
print("x is not in the array")
x is the last element of the array a[]
x is greater than all elements of the array a[]
Both of the Above
x is less than the last element of the array a[]
6.
MULTIPLE CHOICE QUESTION
1 min • 1 pt
Output Prediction:
What will be the output of this Python code?
def mystery(s):
return s[::-1] if len(s) % 2 == 0 else s[1::2]
print(mystery("abcdef"))
print(mystery("12345"))
fedcba and 24
abcdef and 24
fedcba and 135
fabcde and 13
7.
MULTIPLE CHOICE QUESTION
1 min • 1 pt
Matrix Transposition
What will be the output of the following code?
matrix = [[1, 2], [3, 4], [5, 6]]
transpose = [[row[i] for row in matrix] for i in range(2)]
print(transpose)
[[1, 3, 5], [2, 4, 6]]
[[1, 2], [3, 4], [5, 6]]
[[1, 2, 3], [4, 5, 6]]
[[1, 4], [2, 5], [3, 6]]
Create a free account and access millions of resources
Similar Resources on Wayground
15 questions
Quiz Pemrograman Arduino

Quiz
•
10th Grade - University
20 questions
Pretest Alpro Dasar

Quiz
•
University
10 questions
HTML + CSS + JS

Quiz
•
University
16 questions
Session 08: Array

Quiz
•
University
15 questions
Quiz sobre el ornitorrinco y la programación

Quiz
•
8th Grade - University
10 questions
23CSR306_Unit I

Quiz
•
University
10 questions
Quiz Meet 2 Mini SC Programing

Quiz
•
University
10 questions
Les pointeurs et structures en C

Quiz
•
University
Popular Resources on Wayground
50 questions
Trivia 7/25

Quiz
•
12th Grade
11 questions
Standard Response Protocol

Quiz
•
6th - 8th Grade
11 questions
Negative Exponents

Quiz
•
7th - 8th Grade
12 questions
Exponent Expressions

Quiz
•
6th Grade
4 questions
Exit Ticket 7/29

Quiz
•
8th Grade
20 questions
Subject-Verb Agreement

Quiz
•
9th Grade
20 questions
One Step Equations All Operations

Quiz
•
6th - 7th Grade
18 questions
"A Quilt of a Country"

Quiz
•
9th Grade