学习Lesson 13:程序的组织结构与函数调用,函数编写原则及应用示例。

版权申诉
0 下载量 105 浏览量 更新于2024-02-19 收藏 225KB PPTX 举报
Lesson 13 introduces the concept of program organization and function calls in structured program design. The main goal is to teach students how to write programs using structured programming methods. The principles of writing functions are discussed, such as breaking down complex problems into smaller functions to simplify program design and defining commonly used functions to reuse in programs. In one exercise, students are asked to input a number n from the keyboard and output all of its prime factors. For example, if the input is 30, the output should be 2, 3, 5. This exercise requires students to define a function isPrime(int x) that returns 1 if x is a prime number and 0 otherwise. In the main function, students are tasked with iterating from 2 to n/2, checking for factors of n that are also prime numbers, and outputting them. Another example provided is to output a multiplication table. The table consists of a 9x9 grid with row and column headers. This exercise helps students understand the structure of a two-dimensional table and how functions can be used to generate and display the table efficiently. Overall, Lesson 13 emphasizes the importance of organizing programs effectively and using functions to break down tasks into manageable components. Students learn how to design programs in a structured way, making them easier to understand, modify, and maintain. Through practical exercises like finding prime factors and creating multiplication tables, students gain hands-on experience applying these concepts in real-world programming scenarios.