- Học kỳ
- SP2026
- Thời Gian
- 9/5/26
- Loại tài liệu
- PE
PRF193 SP26 B5 NO5 PE
INSTRUCTIONS - PRACTICAL EXAM - PRF193
- PLEASE READ BEFORE STARTING YOUR EXAM
Software Requirements
VS Code 1.100.3 (or newer) or Dev C++ 6.3 on Windows 7 and above.
Students are ONLY Allowed to use:
Student can use study materials like presentation slides, notes, sample codes, program examples,
electronic books stored locally on his / her computer only. Don't use all others Al software system
offline and online (e.g. LM Studio, Ollama, ... ChatGPT, Gemini, Grok, Claude, NotebookLM,
Perplexity, ... ).
Q1 to Q5: procedural programming, please using C programming language.
- Q6: object-oriented programming, you must using C++ with OOP style.
Instructions
. Step 1: Students download given materials from exam software.
. Step 2: Students read questions and prepare answers in the given template.
Step 3: Prepare to submit answer:
o For each question (e.g., question 1), please create one sub-folders named "output" where
you need to put the .exe file.
output
For compile each program, use the following command: gcc File1.c-o output\Qx.exe for
Q1 to Q5
For compile each program, use the following command: g++ main.o File1.cpp File2.cpp-
o output\Qx.exe for Q6
Change File1.c, File1.cpp, File2.cpp corresponding to questionNo requirement file.
· Step 4: Submit solution for each question:
o Choose question number (e.g., 1) in PEA software, and then attach corresponding solution
folder (e.g., 1). Click Submit button to finish submitting this question.
Notes
. Solutions will be marked by Automated Marking Software using .exe file.
(1 mark, file to be edited: Q1.c)
Write a program that reads two floating-point numbers from the keyboard (STDIN).
The program must calculate the average value input values.
Finally, display the result rounded to two decimal places.
Below is an example of how the program will run:
2.5 4.5
2.5 4.756
-2.5 1.5
0 0.0
OUTPUT:
OUTPUT:
OUTPUT:
OUTPUT:
3.50
3.63
=0.50
0.00
Question 2:
(1 mark, file to be edited: Q2.c)
Write a C program that allows the user to input an integer n, followed by n integers from the keyboard.
Based on the given input, display all numbers that are divisible by 3 with a remainder of 2. The printed
numbers must be separated by a single space.
Details
- The first input is an integer n (number of elements).
- The next n inputs are integers.
- A number x is considered valid if:
x mod 3 = 2
Output Requirement
- Print all numbers satisfying the condition, separated by one space.
- If no such number exists, print: "n elements do not satisfy the condition"
The following are two test-cases:
6
-1-2 -3 0 2 5
4
3 6 9 12
OUTPUT:
4 elements do not satisfy the condition
OUTPUT:
2 5
Đính kèm
-
PRF193 SP26 B5 NO5 PE_001.webp51.8 KB · Lượt xem: 7 -
PRF193 SP26 B5 NO5 PE_002.webp26.2 KB · Lượt xem: 6 -
PRF193 SP26 B5 NO5 PE_003.webp27.4 KB · Lượt xem: 7 -
PRF193 SP26 B5 NO5 PE_004.webp32.3 KB · Lượt xem: 4 -
PRF193 SP26 B5 NO5 PE_005.webp32 KB · Lượt xem: 4 -
PRF193 SP26 B5 NO5 PE_006.webp30.8 KB · Lượt xem: 4 -
PRF193 SP26 B5 NO5 PE_007.webp39.7 KB · Lượt xem: 5