Search Header Logo

TECHTRIX2025 BUGHUNT SET5

Authored by Sarmistha Moharer

Other

University

TECHTRIX2025 BUGHUNT SET5
AI

AI Actions

Add similar questions

Adjust reading levels

Convert to real-world scenario

Translate activity

More...

    Content View

    Student View

20 questions

Show all answers

1.

MULTIPLE CHOICE QUESTION

1 min • 1 pt

What's the correct replacement for the faulty line? #include int main() { char *ptr = "Hello"; *ptr = 'h'; // Faulty line printf("%s", ptr); return 0; }

char ptr[] = "Hello";

ptr[0] = 'h';

char *ptr = strdup("Hello");

Both A and C

2.

MULTIPLE CHOICE QUESTION

1 min • 1 pt

What’s the correct way to allocate memory? int *arr; arr = malloc(5 * sizeof(int)); What should be done before using arr?

if (arr == NULL) exit(1);

memset(arr, 0, sizeof(arr));

free(arr);

Nothing, malloc never fails

3.

MULTIPLE CHOICE QUESTION

1 min • 1 pt

What’s wrong with this pointer code? #include void func(int **ptr) { int val = 10; *ptr = &val; } int main() { int *p; func(&p); printf("%d", *p); return 0; }

val goes out of scope

p is uninitialized

No error

Memory leak

4.

MULTIPLE CHOICE QUESTION

1 min • 1 pt

What’s the output? #include int main() { int x = 5; int y = (x++, x + 5); printf("%d", y); return 0; }

5

10

11

Error

5.

MULTIPLE CHOICE QUESTION

1 min • 1 pt

What will be printed? #include int main() { int x = 5; printf("%d", x+++x); return 0; }

10

11

Error

Undefined behavior

6.

MULTIPLE CHOICE QUESTION

1 min • 1 pt

What does this bitwise code print? #include int main() { int a = 5; printf("%d", a & -a); return 0; }

5

1

-5

0

7.

MULTIPLE CHOICE QUESTION

1 min • 1 pt

Find the output. #include int main() { int x = 10; int y = x-- - --x; printf("%d", y); return 0; }

0

2

Undefined

10

Access all questions and much more by creating a free account

Create resources

Host any resource

Get auto-graded reports

Google

Continue with Google

Email

Continue with Email

Classlink

Continue with Classlink

Clever

Continue with Clever

or continue with

Microsoft

Microsoft

Apple

Apple

Others

Others

Already have an account?