80 likes | 189 Vues
In this session, we delve into procedural programming fundamentals, focusing on numeric format conversion and the importance of writing readable code. We will explore key concepts including variable declaration, assignment statements, arithmetic formulas, and loop implementation. Students will learn how to create subroutines and function methods while engaging in hands-on practice through a lab assignment involving the accumulation of inputted numbers. The emphasis will be on performing calculations manually rather than relying on external software for conversions.
E N D
ENGR 330: Today’s Class • Administrative: do you want another lab? • Notes on 11 • Fundamentals of procedural programming • Walking through 11 • Making a subroutine/procedure/method/... R. Smith - University of St Thomas - Minnesota
Notes on 11 • The point is to do numeric format conversion • BY HAND, not by relying on other software • Wanted to get numbers we could calculate with • Not what you get by converting from text decimal to text binary • Good programs are READABLE • I didn’t push this much because I didn’t give you formatting standards R. Smith - University of St Thomas - Minnesota
Procedural Programming • What are the 6 things we do in a program? R. Smith - University of St Thomas - Minnesota
Procedural Programming • What are the 6 things we do in a program? • Declare variables • Assignment statements • Call subroutines/procedures/functions/methods • Arithmetic formulas • If statements • Loops R. Smith - University of St Thomas - Minnesota
Let’s walk through 11 • Declarations • Initializations • Set up the loop • Do the loop • Print the result R. Smith - University of St Thomas - Minnesota
Next Assignment • Accumulate several typed-in numbers • Print the accumulated result • Need a function to read in the number • Make it variable base/radix • Do we want to support hex? • Well, not at first R. Smith - University of St Thomas - Minnesota
Building the function for 12 • Input and output declarations • Making the variable radix work • Awkward loops R. Smith - University of St Thomas - Minnesota
That’s it. • Questions? Creative Commons License This work is licensed under the Creative Commons Attribution-Share Alike 3.0 United States License. To view a copy of this license, visit http://creativecommons.org/licenses/by-sa/3.0/us/ or send a letter to Creative Commons, 171 Second Street, Suite 300, San Francisco, California, 94105, USA. R. Smith - University of St Thomas - Minnesota