
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
10 questions
Quiz 8: Arrays&Vector

Quiz
•
University
16 questions
C programming 2

Quiz
•
University
13 questions
Array of Structure

Quiz
•
University
19 questions
Technotsav'23

Quiz
•
University
11 questions
C Language

Quiz
•
10th Grade - University
15 questions
Common errors in C programming

Quiz
•
University
15 questions
Bootcamp Day 3 - Java Array

Quiz
•
University
20 questions
C - Strings

Quiz
•
University
Popular Resources on Wayground
10 questions
Video Games

Quiz
•
6th - 12th Grade
20 questions
Brand Labels

Quiz
•
5th - 12th Grade
15 questions
Core 4 of Customer Service - Student Edition

Quiz
•
6th - 8th Grade
15 questions
What is Bullying?- Bullying Lesson Series 6-12

Lesson
•
11th Grade
25 questions
Multiplication Facts

Quiz
•
5th Grade
15 questions
Subtracting Integers

Quiz
•
7th Grade
22 questions
Adding Integers

Quiz
•
6th Grade
10 questions
Exploring Digital Citizenship Essentials

Interactive video
•
6th - 10th Grade
Discover more resources for Computers
20 questions
Definite and Indefinite Articles in Spanish (Avancemos)

Quiz
•
8th Grade - University
7 questions
Force and Motion

Interactive video
•
4th Grade - University
36 questions
Unit 5 Key Terms

Quiz
•
11th Grade - University
7 questions
Figurative Language: Idioms, Similes, and Metaphors

Interactive video
•
4th Grade - University
15 questions
Properties of Equality

Quiz
•
8th Grade - University
38 questions
WH - Unit 3 Exam Review*

Quiz
•
10th Grade - University
21 questions
Advise vs. Advice

Quiz
•
6th Grade - University
12 questions
Reading a ruler!

Quiz
•
9th Grade - University