C Programming Output Quiz

C Programming Output Quiz

University

15 Qs

quiz-placeholder

Similar activities

C-Py QUIZ | ROUND 1

C-Py QUIZ | ROUND 1

University

20 Qs

Conocimientos básicos de C

Conocimientos básicos de C

University

20 Qs

OCS752_CP_WEEKLY_TEST3 (20.08.2020)

OCS752_CP_WEEKLY_TEST3 (20.08.2020)

University

20 Qs

Arrays and pointers quiz

Arrays and pointers quiz

University

20 Qs

Coding club Summit Online Quiz

Coding club Summit Online Quiz

University

15 Qs

C - Pointers

C - Pointers

University

10 Qs

Array in C

Array in C

University

10 Qs

C programming syntax quiz

C programming syntax quiz

University

20 Qs

C Programming Output Quiz

C Programming Output Quiz

Assessment

Quiz

Computers

University

Hard

Created by

Karen Tan

FREE Resource

15 questions

Show all answers

1.

MULTIPLE CHOICE QUESTION

3 mins • 20 pts

What will be the output of the following code snippet below? #include int main() { int arr[3] = {10, 20, 30}; printf("%d", arr[1]); return 0; }

10

20

30

Garbage value

2.

MULTIPLE CHOICE QUESTION

3 mins • 20 pts

What will be the output of the following code snippet below? #include int main() { int arr[] = {1, 2, 3, 4, 5}; for (int i = 0; i int main() { int arr[5] = {2, 4, 6, 8, 10}; arr[2] = 12; printf("%d", arr[2]); return 0; }

6

12

10

Compilation Error

3.

MULTIPLE CHOICE QUESTION

3 mins • 20 pts

What will be the output of the following code snippet below? #include <stdio.h>

int main() {

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

for (int i = 0; i < 5; i++)

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

return 0;

}

A) 1 2 3 4 5

B) 5 4 3 2 1

C) Compilation error

D) 0 0 0 0 0

4.

MULTIPLE CHOICE QUESTION

3 mins • 20 pts

What will be the output of the following code snippet below? #include int main() { int arr[] = {5, 10, 15, 20}; int *ptr = arr; printf("%d", *(ptr + 2)); return 0; }

5

10

15

20

5.

MULTIPLE CHOICE QUESTION

3 mins • 20 pts

What will be the output of the following code snippet below? #include <stdio.h>

int main() {

int arr[] = {4, 8, 12, 16};

printf("%lu", sizeof(arr));

return 0;

}

4

16

8

12

6.

MULTIPLE CHOICE QUESTION

3 mins • 20 pts

What will be the output of the following code snippet below? #include <stdio.h>

int main() {

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

int *ptr = arr;

for (int i = 0; i < 3; i++)

printf("%d ", *(ptr + i));

return 0;

}

A) 1 3 5

B) 3 5 1

C) 5 3 1

D) Compilation error

7.

MULTIPLE CHOICE QUESTION

3 mins • 20 pts

What will be the output of the following code snippet below? #include #include int main() { int *arr = (int*) malloc(3 * sizeof(int)); arr[0] = 10; arr[1] = 20; arr[2] = 30; printf("%d", arr[1]); free(arr); return 0; }

10

20

30

Undefined Behavior

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?