This commit is contained in:
louiscklaw
2025-02-01 02:04:02 +08:00
parent 8bf2589af5
commit bfa5b5ff46
79 changed files with 4051 additions and 0 deletions

41
_prompts/step1/step1.cpp Normal file
View File

@@ -0,0 +1,41 @@
#include <iostream>
#include <string>
struct Student {
std::string name;
int maths_marks, chinese_marks, english_marks;
char grade;
};
int main() {
while (true) {
Student student;
std::cout << "Enter name (or 'END' to quit): ";
std::cin >> student.name;
if (student.name == "END") {
break;
}
std::cout << "Enter maths marks: ";
std::cin >> student.maths_marks;
std::cout << "Enter chinese marks: ";
std::cin >> student.chinese_marks;
std::cout << "Enter english marks: ";
std::cin >> student.english_marks;
std::cout << "Enter grade: ";
std::cin >> student.grade;
std::cout << "\nStudent details:\n";
std::cout << "Name: " << student.name << "\n";
std::cout << "Maths marks: " << student.maths_marks << "\n";
std::cout << "Chinese marks: " << student.chinese_marks << "\n";
std::cout << "English marks: " << student.english_marks << "\n";
std::cout << "Grade: " << student.grade << "\n";
}
return 0;
}

17
_prompts/step1/step1.md Normal file
View File

@@ -0,0 +1,17 @@
write a cpp function:
This system collects student details like name, marks in each subject.
using cpp, write a console program:
that accepts user input
- name,
- maths marks,
- chinese marks,
- english marks and
- grade,
loop until user enter "END" as name input
print them out when the user input done