CEG 221 Lesson 1: Review I Mr. David Lippa. Overview: Review of Required Concepts Basic data types –Normal basic types, size_t, time_t Basic programming.

Slides:



Advertisements
Similar presentations
2.1 Program Construction In Java
Advertisements

Etter/Ingber Engineering Problem Solving with C Fundamental Concepts Chapter 4 Modular Programming with Functions.
Modular Programming With Functions
What is a pointer? First of all, it is a variable, just like other variables you studied So it has type, storage etc. Difference: it can only store the.
1 ICS103 Programming in C Lecture 5: Introduction to Functions.
CS 201 Functions Debzani Deb.
CEG 221 Lesson 5: Algorithm Development II Mr. David Lippa.
COMP 14 Introduction to Programming Mr. Joshua Stough February 28, 2005 Monday/Wednesday 11:00-12:15 Peabody Hall 218.
CEG 221 Introduction Mr. David Lippa. Overview Introduction –What’s this course about? A synthesis of language, theory, and application Language: –Programming.
C++ Programming: From Problem Analysis to Program Design, Second Edition Chapter 6: User-Defined Functions I.
CS 201 Functions Debzani Deb.
Top-Down Design with Functions 4 What do programmer’s (not programs!) use as input to the design of a program? –Documentation Problem definition Requirements.
CEG 221 Lesson 4: Algorithm Development I Mr. David Lippa.
CEG 221 Lesson 2: Homogeneous Data Types Mr. David Lippa.
Chapter 6: User-Defined Functions I
1 CSC 1401 S1 Computer Programming I Hamid Harroud School of Science and Engineering, Akhawayn University
CS241 PASCAL I - Control Structures1 PASCAL I - Control Structures Philip Fees CS241.
1 CSC241: Object Oriented Programming Lecture No 07.
CSC 107 – Programming For Science. Science Means Solving Problems  Physics – How does an atom work?
CMSC 104, Version 8/061L18Functions1.ppt Functions, Part 1 of 4 Topics Using Predefined Functions Programmer-Defined Functions Using Input Parameters Function.
Lecture 5: Modular Programming (functions – part 1 BJ Furman 27FEB2012.
CEG 221 Lesson 7: Algorithm Development From Start to Finish Mr. David Lippa.
CSC 107 – Programming For Science. Announcements  Lectures may not cover all material from book  Material that is most difficult or challenging is focus.
Chapter 6: User-Defined Functions I Instructor: Mohammad Mojaddam
CSC 107 – Programming For Science. Today’s Goal  Discuss writing & using functions  How to declare them, use them, & trace them  Could write programs.
CIT 590 Intro to Programming Lecture 4. Agenda Doubts from HW1 and HW2 Main function Break, quit, exit Function argument names, scope What is modularity!
Summary of what we learned yesterday Basics of C++ Format of a program Syntax of literals, keywords, symbols, variables Simple data types and arithmetic.
1 ICS103 Programming in C Lecture 7: Introduction to Functions.
USER-DEFINED FUNCTIONS. STANDARD (PREDEFINED) FUNCTIONS  In college algebra a function is defined as a rule or correspondence between values called the.
Chapter 4: Subprograms Functions for Problem Solving Mr. Dave Clausen La Cañada High School.
Chapters 1-5 Review C++ Class. Chapter 1 – the big picture Objects Class Inheritance Reusability Polymorphism and Overloading.
1 10/18/04CS150 Introduction to Computer Science 1 Functions Divide and Conquer.
C++ / G4MICE Course Session 2 Basic C++ types. Control and Looping Functions in C Function/method signatures and scope.
Engineering Problem Solving with C Fundamental Concepts Chapter 4 Modular Programming with Functions.
Slides created by: Professor Ian G. Harris Hello World #include main() { printf(“Hello, world.\n”); }  #include is a compiler directive to include (concatenate)
C++ Programming: Program Design Including Data Structures, Fourth Edition Chapter 6: User-Defined Functions I.
PHY 107 – Programming For Science. Announcements  Lectures may not cover all material from readings  Material that is most difficult or challenging.
2.1 Functions. Functions in Mathematics f x y z f (x, y, z) Domain Range.
Computer Graphics Basic Maths for Graphics in C++ CO2409 Computer Graphics Week 4.
CSI 3125, Preliminaries, page 1 Data Type, Variables.
Functions Math library functions Function definition Function invocation Argument passing Scope of an variable Programming 1 DCT 1033.
Chapter 3: User-Defined Functions I
C++ Programming: From Problem Analysis to Program Design, Fourth Edition Chapter 6: User-Defined Functions I.
Lecture 15: Course Review BJ Furman ME 30 16MAY2011.
PHY 107 – Programming For Science. Science Means Solving Problems  Physics – How does an atom work?
Objective: To apply the Law of Cosines for finding the length of a missing side of a triangle. Lesson 18 Law of Cosines.
Functions in C++ Top Down Design with Functions. Top-down Design Big picture first broken down into smaller pieces.
Functions, Part 1 of 3 Topics  Using Predefined Functions  Programmer-Defined Functions  Using Input Parameters  Function Header Comments Reading 
IT CS 200: R EPEATATION Lect. Napat Amphaiphan. T HE ABILITY TO DO THE SAME TASK AGAIN BY AGAIN UNTIL THE CONDITION IS MET LOOP 2.
Law of Cosines. h a c A B C x D b - x b To derive the formula, fine the relationship between a, b, c, and A in this triangle. a 2 = (b – x) 2 + h 2 a.
ITM 3521 ITM 352 Functions. ITM 3522 Functions  A function is a named block of code (i.e. within {}'s) that performs a specific set of statements  It.
CHAPTER 5 LESSON 4 The Law of Sines VOCABULARY  None.
Computer Graphics Basic Maths for Graphics in C++
User Interaction and Variables
Chapter 6: User-Defined Functions I
Lesson #6 Modular Programming and Functions.
Lesson #6 Modular Programming and Functions.
Functions, Part 2 of 2 Topics Functions That Return a Value
C-language Lecture By B.S.S.Tejesh, S.Neeraja Asst.Prof.
Functions CIS 40 – Introduction to Programming in Python
2011/11/20: Lecture 15 CMSC 104, Section 4 Richard Chang
Lesson #6 Modular Programming and Functions.
1.4 Rewrite Formulas and Equations
Returning Structures Lesson xx
Chapter 6: User-Defined Functions I
Lesson #6 Modular Programming and Functions.
Functions Divide and Conquer
Fundamental Programming
Functions that return a value
Presentation transcript:

CEG 221 Lesson 1: Review I Mr. David Lippa

Overview: Review of Required Concepts Basic data types –Normal basic types, size_t, time_t Basic programming structure –Flow control / Repetition –Scope –Documentation of code –Modular programming Libraries Pass by reference (in C, by pointer) vs. pass by value Basic algorithm development –Design document –Pseudo code

Basic Types – Signed & Unsigned Signed Types char –Range: [-127, 127] short –Range: [-32767, 32767] int –Range: [ , ] Long –Range: [ , ] Unsigned Types unsigned char –Range: [0, ] unsigned short –Range: [0, ] unsigned int –Range: [0, ] unsigned long –Range: [0, ] size_t / time_t: vary

Basic Types – Signed v. Unsigned Signed Subtracting from MIN –char c = -127 –c-1  2 (8-1) - 1 = 127 Adding to MAX –char c = 127 –c+1  -2 (8-1) - 1 = -127 These apply for ++ as well as -- operators. Unsigned Subtracting from MIN –char c = 0 –c-1  = 255 Adding to MAX –char c = 255 –c+1  0 These apply for ++ as well as -- operators.

Basic Types – Signed v. Unsigned To Generalize for variable var: –Signed subtracting from MIN var - 1  2 (sizeof(var) * 8) –Signed adding to MAX var + 1  -2 (sizeof(var) * 8) -1 – 1 –Unsigned subtracting from MIN var - 1  2 (sizeof(var) * 8) - 1 –Unsigned adding to MAX var + 1  0

Basic Programming Structure Flow Control using if/else Repetition of tasks using loops –for –while –do … while Scope –When you hit a }, non-pointer type declared within its matching { is GONE

Basic Programming Structure Documentation of code –ALWAYS document functions Inputs: arguments Outputs: return values, if applicable High level description (from design document) –ALWAYS document complicated loops Modular programming –Use a library when you can – why reinvent the wheel? –Flow control / Repetition –Scope –Pass by reference (in C, by pointer) vs. pass by value

Basic Programming Structure: Modular Programming Libraries –Predefined functions grouped together by purpose are put in a library. –The interface (how to use) is documented in a header file (.h) Pass by reference (in C, by pointer) vs. pass by value –Reference means the input values Δ –Value means a copy is made

Basic Algorithm Development What is an algorithm? Why develop algorithms? Steps –Data Types (data structures) –Interaction of/between Data Types (functions) –Process (using data structures and their functions to produce a result)

Basic Algorithm Development How do we develop an algorithm? –Use a design document to flush out the general aspects of the algorithm –Use pseudo code to flush out the specifics of the process What goes into a design doc? –What data types & Why –How will the types interact (if at all) –General view of what the algorithm does

Basic Algorithm Development: An Example - SAS Design doc for Side Angle Side Triangulation: –TYPES: Use doubles since acos, etc. take doubles & depending on size of the sides, we might need more accuracy –INTERACTION: The variables are related through the cosine laws formula, where a,b,c are sides and C the angle opposite side c: c 2 = a 2 + b 2 – 2ab cos C

Basic Algorithm Development: An Example - SAS PROCESS: –Ensure that all units are the same (a, b, c are the same units, all angles are in radians) –solve the equation for the variable needed: b = √( c 2 – a 2 + 2ab cos C ) –Flush out to use C functions (make sure to note what libraries are being used!) b = sqrt( pow(c, 2) – pow(a, 2) + 2*a*b*cos(C) ) –Ensure output values are in the proper units

Next Time Grouping/Organizing Data Types & Their Applications –Arrays –Data structures that we will briefly cover today, and in more detail later in the term: Lists Stacks Queues Trees

QUESTIONS