Design and Practice of C Language Programming Course
Editing Team: Information Division Party Branch
01
Course Overview and Objectives
The “C Language Programming” course is an important foundational course for majors such as Communication Engineering, Electronic Information Engineering (Excellence Engineer Direction), Electrical Engineering and Automation. It serves as a programming tool for other professional courses, offered in the first semester, totaling 48 class hours (including 16 hours of experiments), worth 3 credits. This course primarily covers the syntax rules of C language, basic statements, control structures, top-down structured programming methods, and commonly used algorithms, specifically including basic syntax, data types and operators, three program structures (sequential, branching, and looping), arrays, pointers, functions, structures and unions, and files.
Through this course, students will acquire the following abilities.
Objective 1 – Value Guidance: To cultivate students’ scientific spirit, awareness of rules, and systemic view. Students are required to master basic computer knowledge and possess fundamental abilities in process-oriented software design and development. (Supports graduation requirement 1)
Objective 2 – Knowledge Exploration: To master the C language programming and development process, enabling students to establish models and algorithms for problem-solving using computational thinking. (Supports graduation requirement 5)
Objective 3 – Capability Building: To convert natural science, engineering fundamentals, and professional knowledge into corresponding mathematical models, using C language programming to solve complex engineering problems in the engineering field. (Supports graduation requirement 5)
02
Overall Design
1. Guiding Philosophy
In the teaching of the C language programming course, the awareness of rules should be cleverly integrated, allowing students to subtly accept education during lectures and experiments, achieving an unobtrusive educational effect. Students’ computational thinking, algorithmic thinking, and systemic thinking should be gradually cultivated, enhancing their computational thinking ability, algorithm design and analysis ability, and program design and implementation ability.
2. Relationship Between Course Objectives and Teaching
The correspondence between the theoretical teaching content of the course and the course objectives and teaching links is shown in Table 6-1.
■ Table 6-1 Correspondence Between Course Theoretical Teaching Content and Course Objectives and Teaching Links
The correspondence between the experimental teaching content of the course and the course objectives and teaching links is shown in Table 6-2.
■ Table 6-2 Correspondence Between Course Experimental Teaching Content and Course Objectives and Teaching Links
3. Assessment Methods for Course Objectives
This course uses regular performance and final assessment scores to comprehensively evaluate student performance.
Total score = Regular performance × 30% + Final assessment × 70%
Regular performance accounts for 30%: including chapter test scores (10%) and lab reports (20%). Final assessment accounts for 70%: closed-book written exam.
The assessment methods for course objectives are shown in Table 6-3.
■ Table 6-3 Assessment Methods for Course Objectives
03
Typical Case of Rule Awareness Cultivation in College Students – Pathways for Cultivating Rule Awareness
The core of rule awareness lies in recognizing the importance of respecting rules and the willingness to abide by them. It is essential not only to follow the rules in action but also to develop a sense of obligation and responsibility to adhere to them deep within. In C language, the various data types, syntax, arrays, pointers, functions, and other concepts we learn are essentially the rules for interacting with computers. When teachers teach these contents, they are essentially imparting a specific set of rules to students. During the learning process, students need to master the application of these rules through extensive training and develop good programming habits to effectively use C language to write programs that enable computers to work for humanity. Therefore, teaching C language can also be seen as a cultivation of rule awareness. We summarize the following teaching cases to share with everyone.
1. Teaching Objectives and Implementation Process of the Case
Teaching Objective: To cultivate students’ rule awareness through various aspects of course teaching.
The implementation process is as follows.
(1) In the first class, clearly explain the learning requirements of this course to students, introducing the course’s position and application fields, and explicitly informing students of the three teaching objectives of this course, establishing the rules for learning this course. Students should understand that this course is centered around C language programming, using Cfree 5.0 as the experimental platform, and introducing the ideas and methods of structured programming. Through this course, students should be able to apply engineering fundamentals and basic theories of their major to solve practical engineering problems, laying a foundation for subsequent courses in microcontrollers, microcomputer principles, embedded systems, and software courses such as data structures and object-oriented programming.
(2) Cultivating rule awareness in theoretical teaching of the course. Based on the characteristics of the discipline and profession, combined with the professional qualities required for students’ future work, fully utilize the advantages of high-level computer languages, and consistently integrate the cultivation of rule awareness throughout theoretical teaching.
(3) Cultivating rule awareness in experimental teaching of the course. The experimental teaching content of the C language programming course includes basic experiments and comprehensive experiments. Basic experiments primarily aim to cultivate students’ fundamental experimental skills, guiding students to gradually apply the knowledge learned, repeatedly training the formation of algorithm design and analysis abilities, ultimately reinforcing computational thinking abilities. Comprehensive experiments further enhance students’ logical thinking, abstract thinking, algorithmic thinking, and systemic thinking, deepening their understanding and mastery of the knowledge learned, guiding students to comprehensively apply the knowledge learned for systematic programming training, and cultivating their program design and implementation abilities.
2. Implementation Case
1) Explain the syntax rules of data types, functions, and statements in C language.
C language is a process-oriented programming language that contains a large number of commands and functions, and it is essential to clearly explain the relevant concepts and usage rules during the introduction.
(1) Let students know the rules and usage techniques.
[Example 6-1]Representing algorithm rules with flowcharts: C language is a process-oriented language with three basic structures, and each algorithm can be described using a flowchart, which can only contain symbols listed in Figure 6-1.
■ Figure 6-1 Symbols Used in Flowcharts
When it is not possible to draw the entire flowchart on one page, connection points with numbers can be used for annotation, along with flow lines for adjustment. As shown in Figure 6-2, the leftmost flowchart uses connection point ① for annotation due to insufficient space, while the content of annotation ① is drawn in the middle; connection point ② is used to prevent crossing, and connection point ③ is used due to insufficient space and to prevent crossing, with the content of connection point ③ displayed on the far right. With these tools, we can clearly express an algorithm using a flowchart on one page.
■ Figure 6-2 Using Connection Points to Annotate and Adjust Flowchart Layout
(2) Related knowledge points can be integrated for explanation, prompting students to conduct comparative analysis, thereby enabling them to master the rules and usage techniques they must follow.
[Example 6-2]Data Types: As shown in Figure 6-3, we can integrate the three related knowledge points of character type, integer type, and escape characters into one graphic for explanation.
■ Figure 6-3 Integrating Related Knowledge Points
Knowledge Point 1: Character type data can be treated as an integer data of length 1 byte (8 bits), and integer values can be assigned to character type data, where the integer corresponds to the ASCII code value of that character.
Knowledge Point 2: Data in computers can be represented in decimal, hexadecimal, and octal forms. In C language, numbers appearing without any prefix are decimal; numbers prefixed with 0 indicate octal integers, e.g., a=030 indicates an octal number, which corresponds to decimal 24, meaning variable a is assigned the decimal integer 24; numbers prefixed with 0x or 0X indicate hexadecimal numbers, e.g., b=0x30 indicates a hexadecimal number, which corresponds to decimal 48.
Knowledge Point 3: C language has a special form of character constant that starts with a backslash, known as escape characters, e.g., c=’\030′ indicates an octal number, which corresponds to decimal 24, meaning character variable c is assigned the character with ASCII code value of decimal integer 24.
Knowledge Point 4: In C language’s output function printf and input function scanf, formatted characters are used to control the input and output format on the screen. Formatted characters start with %, where %d indicates decimal integers, %o indicates octal integers, %x or %X indicates hexadecimal integers. When appearing in the printf function, it indicates outputting data in the corresponding format on the screen; when appearing in the scanf function, it indicates inputting data in the corresponding format from the keyboard.
Data types are the first knowledge points students encounter in C language. Through this case, students understand the importance of attention to detail, as we are dealing with machines that can only be operated through strict instructions. It is essential to understand and remember the details of each knowledge point to enable the computer to correctly achieve our programming goals. After explaining these knowledge points, the question is posed: How to assign a decimal integer to a character type variable? This prompts students to think further; if they master the four knowledge points discussed, they can easily answer.
(3) Through the teacher’s explanation and students’ practice, continuously reinforce students’ understanding and mastery of the rules.
[Example 6-3]In C language, using functions to implement input and output for the computer.
Computers can only complete input through peripherals such as keyboards and mice, and output the processed results through displays. C language implements user interaction through input function scanf and output function printf, which use formatted characters to standardize data input and output.
Knowledge Point 1: Input and output are defined from the perspective of the computer.
Output refers to data being sent from the computer to output devices (such as displays, printers, etc.). Input refers to data being sent from input devices (such as keyboards, disks, CDs, scanners, etc.) to the computer.
Knowledge Point 2: C language does not provide input and output statements.
Input and output operations are implemented by functions in the C standard library; printf and scanf are not keywords in C language but merely names of library functions. There are also other types of rich input and output functions such as putchar, getchar, puts, gets, etc.
Knowledge Point 3: When using input and output functions, it is necessary to include precompiled directives at the beginning of the program file. This is because the prototypes of these functions are in the header file “stdio.h”, which can be included in the current source file using the preprocessor command “#include” or “#include
Knowledge Point 4: Use formatted characters to implement the design output on the screen. Figure 6-4 shows the syntax format of input and output functions. The calling forms of these two functions are similar, consisting of a format control string and a list of items. The input function scanf is used to input data from the keyboard, and the input data is stored in variables, so the address list consists of several addresses, which can be the addresses of variables or the starting address of strings. The output function printf outputs data through the screen, and the output list consists of data to be output, which can be constants, variables, or expressions.
■ Figure 6-4 Syntax Format of Input and Output Functions
Example code is shown in Figure 6-5, where line 5 declares an integer variable i and assigns it the decimal value 48; line 6 declares three floating-point variables a, b, c; line 7 declares a character variable d and initializes it with the uppercase letter A; line 9 outputs a prompt message, as there are no formatted characters in the format control string, it outputs as is. Line 10 calls the input function scanf, where the format control string specifies the input format. The specific effect is that a black screen with a blinking input cursor appears, allowing the user to input data at the cursor position. According to the format control requirements, data is input from the keyboard for the three variables, with specific input steps as follows.
■ Figure 6-5 Application of Input and Output Functions in Different Scenarios
① After inputting “a=”, input a decimal floating-point number (i.e., at this point, only numbers and decimal points can be input from the keyboard). When encountering a half-width comma “,”, the previously input floating-point number is stored in variable a; ② After inputting “b=”, input a decimal floating-point number (i.e., at this point, only numbers and decimal points can be input from the keyboard). When inputting a half-width comma “,”, it indicates that the current floating-point input is complete, and the input floating-point number is stored in variable b; ③ After inputting “c=”, input a decimal floating-point number (i.e., at this point, only numbers and decimal points can be input from the keyboard). Inputting “Enter”, “Tab”, or “Space” indicates the end of input, and the previously input floating-point number is stored in variable c.
Through this example, various complex situations are set, providing students with different application scenarios for formatted characters. Only by deeply understanding the meaning of each formatted character can the rules be correctly implemented in code, achieving the desired input and output effects for users.
(4) Compare and master the usage techniques of the rules.
[Example 6-4] Understanding the differences in implementing loops using while, do…while, and for statements. First, explain the working principles of each statement, then list the differences and similarities among these three statements for comparative analysis.
The differences are as follows.
① The characteristic of the while loop statement is: it first evaluates the condition expression, then executes the loop body statement. As long as the loop condition expression is true (i.e., the given condition holds), the loop body statement is executed. ② The characteristic of the do-while statement: it first unconditionally executes the loop body, then evaluates whether the loop condition holds. Generally, when using while and do…while statements to handle the same problem, if the loop body parts are the same, the results will also be the same. However, if the expression after while is false (0) from the beginning, the results of the two loops will differ. ③ The for statement is more flexible, as it can be used not only for cases where the number of loops is predetermined but also for cases where the number of loops is uncertain, only providing the loop termination condition. It can completely replace the while statement. Expression 1 sets the initial condition, executed only once. It can set zero, one, or multiple variables to initial values. Expression 2 is the loop condition expression, used to determine whether to continue looping. This expression is executed before each loop body execution to decide whether to continue executing the loop. Expression 3 serves as the loop adjustment, such as incrementing the loop variable, which is executed after the loop body.
The similarities are as follows.
① All three loop structures contain a “statement”, which is the loop body. The loop body can be a simple statement or a compound statement (a series of statements enclosed in braces). The number of times the loop body is executed is controlled by the loop condition, which is the “expression” in the general form above, also known as the loop condition expression. When the value of this expression is “true” (represented by a non-zero value), the loop body statement is executed; when it is “false” (represented by 0), the loop body statement is not executed. ② All can use the break statement to terminate the loop early, transferring control to the statement following the loop body. Note: The break statement can only be used within loop statements and switch statements, and cannot be used alone. ③ All can use the continue statement to end the current loop early, skipping the remaining statements in the loop body. The continue statement only ends the current loop, not the entire loop; while the break statement ends the entire loop, no further evaluation of the loop condition is performed.
(5) Teach methods for debugging in computers, requiring students to master single-step debugging techniques.
[Example 6-5] Single-step debugging is the most direct and effective method for discovering logical errors.
If the program compiles successfully but the runtime result differs from expectations, it indicates a logical error. Logical errors can only be discovered through single-step debugging. As shown in Figure 6-6, users must observe the changes in variables during single-step debugging to determine the impact of each line of code, thereby identifying problematic code and completing modifications. If the program has syntax errors, it cannot compile, and the platform will directly provide the line number and error message, allowing users to repeatedly modify until compilation is successful. It is important to save changes promptly after modifications.
■ Figure 6-6 Single-Step Debugging Window
2) Cultivating rule awareness in experimental teaching of the course
[Example 6-6] Experimental teaching of the course must establish rules for students, strictly requiring them to follow operational norms.
(1) Pre-study the rules and requirements of the experiment.
Students must read the experimental tutorial in advance, clarify the content of the lab experiment, and write the code on their own computers before running and debugging it in the lab.
(2) Rules and requirements during the experimental process.
Students are required to write and debug C programs in the Cfree 5.0 environment to complete the experimental tasks. They must record the results and save screenshots.
(3) Rules and requirements for the experimental report.
Students must write the experimental report using Word, organizing the screenshots taken during the experiment, completing the report according to requirements, and submitting a printed report for teacher evaluation and grading.
04
Teaching Features and Reflections
1. Teaching Features
Each knowledge point in C language is closely related, requiring students to master each point solidly to learn subsequent content comprehensively. This necessitates a strong awareness of rules, completing learning according to course requirements. C language is inherently challenging to learn, requiring rigorous logical thinking and a focused, dedicated learning attitude. This characteristic can inspire students to be grounded in reality and improve themselves step by step.
This course has established a flipped teaching model combining online and offline methods, effectively enhancing students’ programming design abilities and cultivating their rule awareness through four processes: establishing learning objectives, self-directed learning, guiding the learning process, and evaluating learning outcomes.
2. Teaching Reflections
Programming design is an essential skill in the era of artificial intelligence and 5G, serving as a key guarantee for students’ future professional skills. The programming design course can inspire career aspirations, linking career ideals to patriotic education, and from patriotic education to socialist ideals, forming a process of seeing the big picture from small details.
Teachers should guide students to read relevant technology reports, understand cutting-edge computer technologies from multiple perspectives, learn about the development status of developed countries, and recognize the technological gap between our country and developed nations, fostering a strong sense of patriotism that motivates students to study diligently and cultivate their career aspirations and sense of national mission.
Highlights Recap
1. What is curriculum ideological and political education?
2. How to implement curriculum ideological and political education?
3. How to integrate curriculum ideological and political education with the major?
4. Implementation plan for ideological and political education in electronic information majors.
5. Design and practice of cultivating scientific spirit.
6. Design and practice of cultivating craftsmanship spirit.
7. Design and practice of cultivating systemic view.
8. Design and practice of cultivating team spirit.
9. Design and practice of cultivating rule awareness.
05
References
How to Integrate Ideological and Political Content into Textbooks
This book is guided by the “Guidelines for the Construction of Ideological and Political Education in Higher Education Courses”, focusing on the pain points, difficulties, and key issues in professional course teaching, exploring the path of ideological and political education in courses. This book comprehensively and concisely introduces the connotation of ideological and political education, how to understand it, and the existing problems and their causes.
(1) Systematically Design Ideological and Political Content for Professional Courses:Starting from seven aspects: school level, teacher level, teaching objectives, content system, teaching methods, teaching evaluation, and teaching management, exploring the implementation path of ideological and political education in electronic information professional courses.
(2) Clarify Five Professional Ideological and Political Course Objectives:Systematically sorting out the concept of ideological and political education, the implementation path of professional course ideological and political education, and the construction and implementation plan for ideological and political education in electronic information professional courses. The objectives of ideological and political education in electronic information professional courses are clarified as cultivating scientific spirit, craftsmanship spirit, systemic view, teamwork spirit, and rule awareness.
(3) Rich Design Plans for Ideological and Political Education:This book provides 160 complete design and practice plans for ideological and political education across 22 courses in aspects such as cultivating scientific spirit, craftsmanship spirit, systemic view, teamwork spirit, and rule awareness.