TECHTRIX2025 BUGHUNT SET6

TECHTRIX2025 BUGHUNT SET6

University

20 Qs

quiz-placeholder

Similar activities

Luyện tập 1

Luyện tập 1

University

20 Qs

Mindzone Season-3

Mindzone Season-3

University

15 Qs

Tech quiz Round 1

Tech quiz Round 1

University

15 Qs

Funções e Estruturas - Matrizes & Strings & Apontadores

Funções e Estruturas - Matrizes & Strings & Apontadores

9th Grade - Professional Development

24 Qs

CodeQuest-R1

CodeQuest-R1

University

20 Qs

Round 2- Syntax ShowDown

Round 2- Syntax ShowDown

University

25 Qs

Blind coding

Blind coding

University

15 Qs

Quiz on Array

Quiz on Array

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?