Search Header Logo

DSA quiz

Authored by JEYASARAVANAN JEYASARAVANAN

Computers

University

Used 1+ times

DSA quiz
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

30 sec • 1 pt

#include <stdio.h>

int main() {

int a = 5;

int b = a+++a;

printf("%d", b);

return 0;

}

What happens?

Prints 11

Prints 10

Compile error

Runtime error

2.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

#include <iostream>

using namespace std;

int main() {

int arr[3] = {1, 2, 3};

cout << arr[3];

return 0;

}

What happens?

Prints 0

Undefined behavior (may print garbage)

Compile error

Prints 3

3.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

#include <stdio.h>

int main() {

char str[5] = "Hello";

printf("%s", str);

return 0;

}

What happens?

Prints Hello

Compile error: string too long

Prints Hell

Runtime error

4.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

#include <iostream>

using namespace std;

int main() {

int *p = NULL;

cout << *p;

}

Prints 0

Prints garbage

Compile error

Runtime segmentation fault

5.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

#include <stdio.h>

int main() {

int x = 10;

printf("%d", ++x++);

return 0;

}

Prints 12

Compile error

Prints 11

Undefined behavior

6.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

#include <iostream>

using namespace std;

int main() {

string s = "abc";

s[3] = 'd';

cout << s;

}

Prints abcd

Runtime error

Prints abc

Prints garbage

7.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

#include <stdio.h>

int main() {

int a = 5, b = 2;

printf("%d", a+++b);

return 0;

}

8

7

6

Compile error

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?