TECHTRIX2025 BUGHUNT SET6

TECHTRIX2025 BUGHUNT SET6

University

20 Qs

quiz-placeholder

Similar activities

Zmienna losowa ciągła

Zmienna losowa ciągła

University

15 Qs

Basic Integration

Basic Integration

12th Grade - University

17 Qs

Numpy Quiz

Numpy Quiz

University

20 Qs

Quiz on Arrays, Inheritance, and Interfaces in Java

Quiz on Arrays, Inheritance, and Interfaces in Java

University

15 Qs

Together We Grow - 2

Together We Grow - 2

University

15 Qs

Javapie Quiz

Javapie Quiz

University

20 Qs

First Meet Sains Data 2022

First Meet Sains Data 2022

University

20 Qs

TECHTRIX2025 BUGHUNT SET4

TECHTRIX2025 BUGHUNT SET4

University

20 Qs

TECHTRIX2025 BUGHUNT SET6

TECHTRIX2025 BUGHUNT SET6

Assessment

Quiz

Other

University

Hard

Created by

Sarmistha Moharer

FREE Resource

20 questions

Show all answers

1.

MULTIPLE CHOICE QUESTION

1 min • 1 pt

What is the error in the following C code? #include int main() { int arr[3] = {1, 2, 3}; printf("%d", arr[3]); return 0; } Explanation: The array has indices from 0 to 2. Accessing arr[3] is out of bounds.

printf("%d", arr[2]);

printf("%d", arr[3]); (No error)

printf("%d", arr[0]);

printf("%d", arr[4]);

2.

MULTIPLE CHOICE QUESTION

1 min • 1 pt

What should be the correct condition in this code? #include int main() { int x = 5; if (x = 10) { printf("Hello"); } return 0; } Explanation: x = 10 is an assignment, not a comparison. Use == for comparison.

if (x = 10)

if (x == 10)

if x == 10;

if (x := 10)

3.

MULTIPLE CHOICE QUESTION

1 min • 1 pt

Identify the correct line to fix the segmentation fault. #include int main() { int *ptr; *ptr = 10; printf("%d", *ptr); return 0; } Explanation: The pointer is uninitialized, leading to undefined behavior. Assign a valid memory address.

int ptr = 10;

int *ptr = NULL;

int x = 10; int *ptr = &x;

int *ptr = 10;

4.

MULTIPLE CHOICE QUESTION

1 min • 1 pt

Find the correct way to swap two numbers using pointers. #include void swap(int *a, int *b) { int temp = *a; *a = *b; *b = temp; } int main() { int x = 5, y = 10; swap(x, y); printf("%d %d", x, y); return 0; } Explanation: The function expects pointers, so we must pass the addresses of x and y.

swap(x, y);

swap(&x, &y);

swap(*x, *y);

swap(x, *y);

5.

MULTIPLE CHOICE QUESTION

1 min • 1 pt

Identify the correct loop termination condition. #include int main() { int i = 0; while (i = 10) { printf("%d", i); i++; } return 0; } Explanation: i = 10 is an assignment, not a condition. The loop should run until i < 10.

while (i = 10)

while (i == 10)

while (i < 10)

while (i <= 10)

6.

MULTIPLE CHOICE QUESTION

1 min • 1 pt

What will be the output? #include int main() { printf("%d", printf("RCCIIT")); return 0; } Explanation: printf("RCCIIT") prints "RCCIIT" and returns 6, which is printed by the second printf.

RCCIIT

6

RCCIIT6

Error

7.

MULTIPLE CHOICE QUESTION

1 min • 1 pt

What is the output? #include int main() { int x = 6, y = 1; if (x & y) { printf("Yes"); } else { printf("No"); } return 0; } Explanation: 6 & 1 results in 0 (bitwise AND), so the else block executes.

Yes

No

0

Error

Create a free account and access millions of resources

Create resources
Host any resource
Get auto-graded reports
or continue with
Microsoft
Apple
Others
By signing up, you agree to our Terms of Service & Privacy Policy
Already have an account?