
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
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
Similar Resources on Wayground
20 questions
C programming syntax quiz

Quiz
•
University
12 questions
C Practice Test 1

Quiz
•
University
19 questions
C Language Array Quiz

Quiz
•
University
10 questions
Arrays

Quiz
•
11th Grade - University
13 questions
C programming-1

Quiz
•
University
10 questions
Arrays in C (II yr 02.07.2020)

Quiz
•
University
10 questions
C Program Array and strings

Quiz
•
University
10 questions
Array in C

Quiz
•
University
Popular Resources on Wayground
18 questions
Writing Launch Day 1

Lesson
•
3rd Grade
11 questions
Hallway & Bathroom Expectations

Quiz
•
6th - 8th Grade
11 questions
Standard Response Protocol

Quiz
•
6th - 8th Grade
40 questions
Algebra Review Topics

Quiz
•
9th - 12th Grade
4 questions
Exit Ticket 7/29

Quiz
•
8th Grade
10 questions
Lab Safety Procedures and Guidelines

Interactive video
•
6th - 10th Grade
19 questions
Handbook Overview

Lesson
•
9th - 12th Grade
20 questions
Subject-Verb Agreement

Quiz
•
9th Grade