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; }

C Programming Output Quiz

Quiz
•
Computers
•
University
•
Hard
Karen Tan
FREE Resource
15 questions
Show all answers
1.
MULTIPLE CHOICE QUESTION
3 mins • 20 pts
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
Similar Resources on Quizizz
16 questions
C programming 2

Quiz
•
University
15 questions
Coding club Summit Online Quiz

Quiz
•
University
10 questions
C - Pointers

Quiz
•
University
20 questions
C - Structures

Quiz
•
University
10 questions
Java Arrays

Quiz
•
University
10 questions
Basics Of C Programming

Quiz
•
University
10 questions
Basics of C

Quiz
•
University
20 questions
C - Strings

Quiz
•
University
Popular Resources on Quizizz
15 questions
Character Analysis

Quiz
•
4th Grade
17 questions
Chapter 12 - Doing the Right Thing

Quiz
•
9th - 12th Grade
10 questions
American Flag

Quiz
•
1st - 2nd Grade
20 questions
Reading Comprehension

Quiz
•
5th Grade
30 questions
Linear Inequalities

Quiz
•
9th - 12th Grade
20 questions
Types of Credit

Quiz
•
9th - 12th Grade
18 questions
Full S.T.E.A.M. Ahead Summer Academy Pre-Test 24-25

Quiz
•
5th Grade
14 questions
Misplaced and Dangling Modifiers

Quiz
•
6th - 8th Grade