
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
Input And Output in C

Quiz
•
University
11 questions
Basics of JAVA

Quiz
•
University
12 questions
MPMNJ C Training (Control Statements Quiz)

Quiz
•
University
8 questions
DS_A1 batch viva1 &2

Quiz
•
University
10 questions
Array in C

Quiz
•
University
13 questions
C programming-1

Quiz
•
University
10 questions
Arrays

Quiz
•
11th Grade - University
15 questions
C Language Quiz-1

Quiz
•
University - Professi...
Popular Resources on Wayground
10 questions
Lab Safety Procedures and Guidelines

Interactive video
•
6th - 10th Grade
10 questions
Nouns, nouns, nouns

Quiz
•
3rd Grade
10 questions
9/11 Experience and Reflections

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

Quiz
•
5th Grade
11 questions
All about me

Quiz
•
Professional Development
22 questions
Adding Integers

Quiz
•
6th Grade
15 questions
Subtracting Integers

Quiz
•
7th Grade
9 questions
Tips & Tricks

Lesson
•
6th - 8th Grade
Discover more resources for Computers
21 questions
Spanish-Speaking Countries

Quiz
•
6th Grade - University
20 questions
Levels of Measurements

Quiz
•
11th Grade - University
7 questions
Common and Proper Nouns

Interactive video
•
4th Grade - University
12 questions
Los numeros en español.

Lesson
•
6th Grade - University
7 questions
PC: Unit 1 Quiz Review

Quiz
•
11th Grade - University
7 questions
Supporting the Main Idea –Informational

Interactive video
•
4th Grade - University
12 questions
Hurricane or Tornado

Quiz
•
3rd Grade - University
7 questions
Enzymes (Updated)

Interactive video
•
11th Grade - University