tailieunhanh - Lecture Introduction to computer and programming - Lecture No 13

The contents of this chapter include all of the following: Describe the basic elements of a computer system and their interrelationship, eplain the steps taken by a processor to execute an instruction, understand the concept of interrupts and how and why a processor uses interrupts,. | CSC103: Introduction to Computer and Programming Lecture No 13 Previous lecture A menu driven program using if else switch case Nested case control structure A calculator (add, subtract, multiply) Factorial, prime, even/odd Today’s lecture outline Introduction to structure programming Function definition Function call Function prototype Structured programming It enables programmers to break complex systems into manageable components In C, these components are known as functions A function is a block of statements that perform a task Every C program can be thought of as a collection of these functions Structured programming concepts Top-down design Code reusability Information hiding Top-down design To demonstrate let see ATM (Automated Teller Machine) as an example Suppose your boss assigns you to program the software for a ATM system Question for you is where to begin as it's a large task filled with complexities and many details ATM example - Cont. Top-down design helps you to design complex program The following steps demonstrate the top-down design process Break the problem into small, manageable components, starting from the top. In C, the top component is the main() function from which other components are called ATM example - Cont. 2. Identify all major components. For the ATM example, assume there are four major components: Display balance Deposit funds Transfer funds Withdraw funds 3. Decompose one major component at a time and make it more manageable and less complex ATM example – Cont. 4. The withdraw funds component can be decomposed into following sub-components Get available balance Compare available balance to amount requested Update customer’s account Distribute approved funds Reject request Print receipt ATM example – Cont. 5. Go even further with the decomposition process and divide the “distribute approved funds” component even smaller: Verify ATM funds exist Initiate mechanical processes Update bank records Decomposing ATM system—top-down design | CSC103: Introduction to Computer and Programming Lecture No 13 Previous lecture A menu driven program using if else switch case Nested case control structure A calculator (add, subtract, multiply) Factorial, prime, even/odd Today’s lecture outline Introduction to structure programming Function definition Function call Function prototype Structured programming It enables programmers to break complex systems into manageable components In C, these components are known as functions A function is a block of statements that perform a task Every C program can be thought of as a collection of these functions Structured programming concepts Top-down design Code reusability Information hiding Top-down design To demonstrate let see ATM (Automated Teller Machine) as an example Suppose your boss assigns you to program the software for a ATM system Question for you is where to begin as it's a large task filled with complexities and many details ATM example - Cont. Top-down design helps you to .

TỪ KHÓA LIÊN QUAN