What is the output of the following C code?
#include <stdio.h>
int main() {
int arr[] = {1, 3, 5, 7, 9};
int *p = arr;
printf("%d", *(p + 3));
return 0;
}
HackTrail
Quiz
•
Computers
•
University
•
Hard
Dheeraj Vishwakarma
Used 2+ times
FREE Resource
15 questions
Show all answers
1.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What is the output of the following C code?
#include <stdio.h>
int main() {
int arr[] = {1, 3, 5, 7, 9};
int *p = arr;
printf("%d", *(p + 3));
return 0;
}
1
5
7
9
2.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What is the output of this recursive function in Python?
def func(n):
if n == 0:
return 0
return n + func(n - 1)
print(func(5))
Infinite recursion
5
10
15
3.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What is the output of this Python code?
def dfs(graph, v, visited=set()):
visited.add(v)
for neighbor in graph[v]:
if neighbor not in visited:
dfs(graph, neighbor, visited)
return visited
graph = {'A': ['B'], 'B': ['C'], 'C': ['A']}
print(dfs(graph, 'A'))
Error
{'A'}
{'A', 'C'}
{'A', 'B', 'C'}
4.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
Time complexity of the following C function?
void fun(int n) {
for (int i = 1; i <= n; i *= 2)
printf("%d ", i);
}
O(n)
O(log n)
O(n log n)
O(1)
5.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
Output of the Python code:
a = [1, 2, 3]
b = a
b.append(4)
print(a)
[1, 2, 3]
[1, 2, 3, 4]
[1, 2, 4]
Error
6.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
Which queue implementation allows insertion and deletion at both ends?
LinkedList
Queue
PriorityQueue
Dequeue
7.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
char str[] = "HackTrail";
printf("%c", *(str + 4));
T
r
a
k
10 questions
C Program Array and strings
Quiz
•
University
15 questions
BASIC C PROGRAMMING QUIZ
Quiz
•
University
16 questions
PSC ALM QUIZ
Quiz
•
University
10 questions
Array in C
Quiz
•
University
18 questions
C Language 101
Quiz
•
University
10 questions
Expression in C Programming
Quiz
•
University
13 questions
C programming-1
Quiz
•
University
12 questions
Operators in C
Quiz
•
University
10 questions
Chains by Laurie Halse Anderson Chapters 1-3 Quiz
Quiz
•
6th Grade
20 questions
math review
Quiz
•
4th Grade
15 questions
Character Analysis
Quiz
•
4th Grade
12 questions
Multiplying Fractions
Quiz
•
6th Grade
30 questions
Biology Regents Review #1
Quiz
•
9th Grade
20 questions
Reading Comprehension
Quiz
•
5th Grade
20 questions
Types of Credit
Quiz
•
9th - 12th Grade
50 questions
Biology Regents Review: Structure & Function
Quiz
•
9th - 12th Grade
10 questions
Identifying equations
Quiz
•
KG - University
16 questions
Chapter 8 - Getting Along with your Supervisor
Quiz
•
3rd Grade - Professio...
6 questions
Railroad Operations and Classifications Quiz
Quiz
•
University
71 questions
Logos
Quiz
•
3rd Grade - University
8 questions
Mali - Geography
Quiz
•
University