CMDP2063 Unix and C Programming (Revision)

Quiz
•
Information Technology (IT)
•
University
•
Easy

Hanley Fong
Used 1+ times
FREE Resource
15 questions
Show all answers
1.
MULTIPLE CHOICE QUESTION
2 mins • 1 pt
What does the fopen() function do when opening a file in "r" mode?
Opens a file for both reading and writing
Opens a file for appending data to it
Opens a file for reading only
Creates a new file for writing
Answer explanation
The "r" mode in fopen() opens the file for reading only
2.
MULTIPLE CHOICE QUESTION
2 mins • 1 pt
What is the primary difference between printf() and fprintf() in C?
fprintf() is used for reading input from a file, while printf() writes to a file.
fprintf() is used for file output, while printf() is used for console output.
fprintf() is slower than printf() because it works with larger files.
fprintf() writes output to the console, while printf() writes to files.
3.
MULTIPLE CHOICE QUESTION
2 mins • 1 pt
Which of the following is the correct use of fgets() to read a line of text from a file?
fgets(str, INPUT_SIZE, f);
fgets(str, INPUT_SIZE, "input.txt");
fgets(str, 100, "file.txt");
fgets("text.txt", 100, str);
Answer explanation
The correct syntax for fgets() is fgets(str, INPUT_SIZE, f); where str is the array to store the text, INPUT_SIZE is the size of the buffer, and f is the pointer to the file.
4.
MULTIPLE CHOICE QUESTION
2 mins • 1 pt
In the following code, which of the following is the correct way to access the month field of the nested struct?
5.
MULTIPLE CHOICE QUESTION
2 mins • 1 pt
After allocating memory for a struct named door with malloc(), which function should be used to deallocate the memory?
delete(door);
free(door);
destroy(door);
deallocate(door);
6.
MULTIPLE CHOICE QUESTION
2 mins • 1 pt
Which of the following is a valid initialization of a Result struct?
Result res = {75, "B"};
Result res = {'B', 75};
Result res = {75, 'B'};
Result res = {grade = 'B', mark = 75};
7.
MULTIPLE CHOICE QUESTION
2 mins • 1 pt
What is the primary purpose of a debugger?
To automatically fix errors in code
To compile and run code more efficiently.
To optimize code performance.
To help debug software by allowing users to inspect and control a running program.
Create a free account and access millions of resources
Similar Resources on Wayground
15 questions
Linux Basics for Beginners

Quiz
•
University
16 questions
Backup dan Restore Data

Quiz
•
12th Grade - University
16 questions
ICDL K4_ Xử lý văn bản P1_5*

Quiz
•
5th Grade - University
15 questions
Mengetahui Web Browser

Quiz
•
9th Grade - University
10 questions
quiz sistem operasi

Quiz
•
University
20 questions
KUIS TIK

Quiz
•
9th Grade - University
20 questions
FINALS summative test in TRENDS

Quiz
•
12th Grade - University
10 questions
Post Test (JKI)

Quiz
•
10th Grade - 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 Information Technology (IT)
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