Lab01-Review-Array-String-Struct-File IO
Lab01-Review-Array-String-Struct-File IO
Lab 01
Review
1
Notes
Create a single solution/folder to store your source code in a week.
Then, create a project/sub-folder to store your source code of each assignment.
The source code in an assignment should have at least 3 files:
• A header file (.h): struct definition, function prototypes/definition.
• A source file (.cpp): function implementation.
• Another source file (.cpp): named YourID_Ex01.cpp, main function. Replace 01 by id of an
assignment.
Make sure your source code was built correctly. Use many test cases to check your code before
submitting to Moodle.
Name of your submission StudentID_Week_NumCompleteAssignments.zip, for example:
18125001_W01_07.zip
2
CSC10002 L01 – Review
2
Content
In this lab, we will review the following topics:
• How to create a project with multiple source code files, at least 1 header file, 1 source file and 1
main() source file.
• How to declare, define and call a function.
• How to use array.
• How to use C-string.
• How to use struct.
• How to load data from a text file, or save data to a text file.
3
CSC10002 L01 – Review
3
Assignments
A: YY: 01 problem / assignment.
H: YY: 05 problems / assignments.
You must submit at least 3 files for each project/assignment: a header file to declare all structures and
functions, a cpp file to implement all declared functions and another cpp file containing your main()
function.
3.1. Assignment 1
Write a program to load an array of dates. Sort the array in ascending order and save the array to
another text file.
For example: in the below file, there are THREE dates. The last line indicates that there is no more date
to load.
input.txt
2019 1 4
2019 12 31
2019 1 15
-1 -1 -1
3.2. Assignment 2
Write a program to load an array of students (id, full name, gpa) from a text file, named “input.txt”. Find
top best-GPA students and output to another text file, named “honors.txt”. The structure/format of 2 files
must be the same.
From now, for Codeforces/Hackerrank/Leetcode… assignments, you need to submit 2 files: a source
code cpp file, and an image/screenshot to prove that your code is ACCEPTED on
Codeforces/Hackerrank/Leetcode.
3.3. Assignment 3
http://codeforces.com/problemset/problem/10/A
3.4. Assignment 4
http://codeforces.com/problemset/problem/11/A
4
CSC10002 L01 – Review
3.5. Assignment 5
Students are asked to record a video to show how to create project with multiple source files, compile,
run and debug in the project using your chosen IDE (Visual Studio, Visual Code, CodeBlock, XCode,
CLion…)
Upload the video in your Youtube account in Unlist or Public mode.
Submit the video link.