
C quiz

Quiz
•
Computers
•
University
•
Hard
Giri A
Used 5+ times
FREE Resource
10 questions
Show all answers
1.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
#include <stdio.h>
int main() {
int arr[] = {10, 20, 30, 40, 50};
int *ptr = arr;
ptr = ptr + 2;
printf("%d ", *(ptr + 1));
return 0;
}
30
40
50
20
2.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
#include <stdio.h>
#include <string.h>
int main() {
char str[] = "Hello, world!";
printf("%d", strlen(str));
return 0;
}
13
14
12
Undefined behaviour
3.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
#include <stdio.h>
#include <stdlib.h>
int main() {
int *arr = (int *)calloc(3, sizeof(int));
arr[1] = 10;
arr[2] = 20;
free(arr);
printf("%d", arr[2]);
return 0;
}
0
10
20
Undefined behavior
4.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
#include <stdio.h>
#include <stdlib.h>
int main() {
int *arr = (int*)malloc(10 * sizeof(int));
free(arr);
arr[0] = 5;
printf("%d", arr[0]);
return 0;
}
It will print 5.
It will print 0.
It will give a runtime error due to accessing freed memory.
It will give a compilation error.
5.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
#include <stdio.h>
int main() {
int x = 5; // Binary: 0101
x = x << 1;
printf("%d", x);
return 0;
}
5
10
20
2
6.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
#include <stdio.h>
struct Person {
char name[30];
int age;
}
int main() {
struct Person persons[2] = {{"John", 25}, {"Jane", 30}};
printf("%d", persons[1].age);
return 0;
}
persons[1].name
persons[0].age
persons[1].age
persons[0].name
7.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
#include <stdio.h>
int main() {
for (int i = 0; i >= 0; i++) {
printf("%d ", i);
}
return 0;
}
The loop will terminate after one iteration.
The loop will run forever.
The loop will run 0 iterations.
It will cause a segmentation fault.
Create a free account and access millions of resources
Similar Resources on Wayground
10 questions
csharp

Quiz
•
University
10 questions
C Program Array and strings

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

Quiz
•
University
15 questions
CIS1101-programming practice

Quiz
•
University
10 questions
pointers and structures

Quiz
•
University
10 questions
C Viva

Quiz
•
University
6 questions
Part1 Array

Quiz
•
University
12 questions
Programming Quiz

Quiz
•
University
Popular Resources on Wayground
10 questions
Video Games

Quiz
•
6th - 12th Grade
10 questions
Lab Safety Procedures and Guidelines

Interactive video
•
6th - 10th Grade
25 questions
Multiplication Facts

Quiz
•
5th Grade
10 questions
UPDATED FOREST Kindness 9-22

Lesson
•
9th - 12th Grade
22 questions
Adding Integers

Quiz
•
6th Grade
15 questions
Subtracting Integers

Quiz
•
7th Grade
20 questions
US Constitution Quiz

Quiz
•
11th Grade
10 questions
Exploring Digital Citizenship Essentials

Interactive video
•
6th - 10th Grade
Discover more resources for Computers
10 questions
Would you rather...

Quiz
•
KG - University
20 questions
Definite and Indefinite Articles in Spanish (Avancemos)

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

Interactive video
•
4th Grade - University
10 questions
The Constitution, the Articles, and Federalism Crash Course US History

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

Interactive video
•
4th Grade - University
20 questions
Levels of Measurements

Quiz
•
11th Grade - University
16 questions
Water Modeling Activity

Lesson
•
11th Grade - University
10 questions
ACT English prep

Quiz
•
9th Grade - University