Computer Programming w/Eng. Applications

Slides:



Advertisements
Similar presentations
Etter/Ingber Engineering Problem Solving with C Fundamental Concepts Chapter 1 Engineering Problem Solving.
Advertisements

By Anthony Campanaro & Dennis Hernandez
Computer Programming w/ Eng. Applications
4/23/2015Engineering Problem Solving with C++ second edition, J. ingber 1 Engineering Problem Solving with C++, Etter/Ingber Chapter 1.
Evaluating Thinking Through Intellectual Standards
ICS103 Programming in C Lecture 1: Overview of Computers & Programming
Lecture 1: Overview of Computers & Programming
Chapter 1 - An Introduction to Computers and Problem Solving
COSC 120 Computer Programming
Engineering Problem Solving With C++ An Object Based Approach Fundamental Concepts Chapter 1 Engineering Problem Solving.
Ch. 1 Engineering Problem Solving. Contents I.Engineering in the Twenty-First Century II.Computing Systems: Hardware and Software III.An Engineering Problem-Solving.
1 Engineering Problem Solving With C++ An Object Based Approach Fundamental Concepts Chapter 1 Engineering Problem Solving.
CS 201 Overview of Computers & Programming Debzani Deb.
1 Lecture 1  Getting ready to program  Hardware Model  Software Model  Programming Languages  The C Language  Software Engineering  Programming.
Introduction to C++ Programming CS 117 Section 2 and KNET Sections Spring 2001 MWF 1:40-2:30.
C++ Programming: From Problem Analysis to Program Design, Third Edition Chapter 1: An Overview of Computers and Programming Languages C++ Programming:
Starting Out with C++: Early Objects 5/e © 2006 Pearson Education. All Rights Reserved Starting Out with C++: Early Objects 5 th Edition Chapter 1 Introduction.
Introduction to Computers and Programming
CS102 Introduction to Computer Programming
Principles of Programming Chapter 1: Introduction  In this chapter you will learn about:  Overview of Computer Component  Overview of Programming 
DCT 1123 PROBLEM SOLVING & ALGORITHMS INTRODUCTION TO PROGRAMMING.
Alternate Version of STARTING OUT WITH C++ 4 th Edition Chapter 1 Introduction to Computers and Programming.
Chapter Introduction to Computers and Programming 1.
CSC 125 Introduction to C++ Programming Chapter 1 Introduction to Computers and Programming.
CMPT 300: Operating Systems
Chapter 1 Engineering Problem Solving 1. Hardware and Software 2 A computer is a machine designed to perform operations specified with a set of instructions.
1 TOPIC 1 INTRODUCTION TO COMPUTER SCIENCE AND PROGRAMMING Topic 1 Introduction to Computer Science and Programming Notes adapted from Introduction to.
Copyright © 2009 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 1: Introduction to Computers and Programming.
Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Starting Out with C++ Early Objects Seventh Edition by Tony Gaddis, Judy.
Introduction to Programming Lecture No. 1. Books  Deitel & Deitel :– C++ How to Program  Kernighan and Ritchie:- The C Programming Language.
Algorithms CS139 – Aug 30, Problem Solving Your roommate, who is taking CS139, is in a panic. He is worried that he might lose his financial aid.
C++ Programming Language Lecture 2 Problem Analysis and Solution Representation By Ghada Al-Mashaqbeh The Hashemite University Computer Engineering Department.
Robert Crawford, MBA West Middle School.  Explain how the binary system is used by computers.  Describe how software is written and translated  Summarize.
EG280 Computer Science for Engineers Fundamental Concepts Chapter 1.
1 Turgay Korkmaz Office: NPB Phone: (210) Fax: (210) web:
Intermediate 2 Software Development Process. Software You should already know that any computer system is made up of hardware and software. The term hardware.
COMPUTER PROGRAMMING. Computer programming the objective of the module to gain the necessary skills to develop a computer program using one of the high.
B.Ramamurthy11/9/20151 Computers and Programming Bina Ramamurthy 127 Bell Hall
12/4/20151 Introduction To Computer Science Bina Ramamurthy.
CS 127 Introduction to Computer Science. What is a computer?  “A machine that stores and manipulates information under the control of a changeable program”
Computing Systems & Programming ECE Fundamental Concepts Chapter 1 Engineering Problem Solving.
Chapter 1 Computers, Compilers, & Unix. Overview u Computer hardware u Unix u Computer Languages u Compilers.
Chapter 1 : Overview of Computer and Programming By Suraya Alias
Copyright 2003 Scott/Jones Publishing Standard Version of Starting Out with C++, 4th Edition Chapter 1 Introduction to Computers and Programming.
Programming Fundamentals Lecture No. 2. Course Objectives Objectives of this course are three fold 1. To appreciate the need for a programming language.
Introduction ELEC 206 Computer Applications for Electrical Engineers Dr. Ron Hayne.
Computer and Programming. Computer Basics: Outline Hardware and Memory Programs Programming Languages and Compilers.
The Hashemite University Computer Engineering Department
Course Aims This course will help you understand the latest technologies & how they work. You will lean how to develop computer programs to solve problems.
Introduction to Computer Programming using Fortran 77.
Copyright © 2014, 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Starting Out with C++ Early Objects Eighth Edition by Tony Gaddis,
C++ Programming: From Problem Analysis to Program Design, Fifth Edition Chapter 1: An Overview of Computers and Programming Languages.
Introduction to Computer Programming Concepts M. Uyguroğlu R. Uyguroğlu.
Victoria Ibarra Mat:  Generally, Computer hardware is divided into four main functional areas. These are:  Input devices Input devices  Output.
 Programming methodology: ◦ is a process of developing programs that involves strategically dividing important tasks into functions to be utilized by.
Chapter 1: Introduction to Computers and Programming
A Guide to Critical Thinking Concepts and Tools
BASIC PROGRAMMING C SCP1103 (02)
Engineering Problem Solving With C An Object Based Approach
Chapter 1: An Overview of Computers and Programming Languages
BASIC PROGRAMMING C SCP1103 (02)
ICS103 Programming in C Lecture 1: Overview of Computers & Programming
Lecture 2 Introduction to Programming
C++ Programming: From Problem Analysis to Program Design
Chapter 1: Introduction to Computers and Programming
Computer Science I CSC 135.
Introduction CSC 111.
Zimbabwe 2008 Critical Thinking.
ICS103 Programming in C 1: Overview of Computers And Programming
Chapter 1: Introduction to Computers and Programming
Presentation transcript:

Computer Programming w/Eng. Applications CS 2073 Computer Programming w/Eng. Applications Ch 1 Turgay Korkmaz Office: SB 4.01.13 Phone: (210) 458-7346 Fax: (210) 458-4437 e-mail: korkmaz@cs.utsa.edu web: www.cs.utsa.edu/~korkmaz

Name Addr Content Lecture 2 Lecture++;

Ch1: Engineering Problem Solving Read Section 1.1 from the textbook Recent Engineering Achievements Microprocessor Moon landing Satellites Computer-aided design (CAD) and manufacturing Jumbo jet Advance computer materials Computerized axial tomography Genetic engineering Lasers Optical fiber Changing Engineering Environment Communication skills (oral, written) Concept-Design-process-manufacture Interdisciplinary teams Word marketplace Analyzing-Synthesizing Societal Context

Ch1: Engineering Problem Solving (cont’d) Section 1.2: Computing Systems Computer: a machine that is designed to perform operations (set of instructions called program) to achieve a specific task (e.g., 3+4) Hardware: computer equipment (e.g., keyboard, mouse, terminal, hard disk, printer) Software: programs that describe the steps we want the computer to perform.

Computer Hardware CPU - Central processing unit Internal Memory External Memory CPU Processor Input Output ALU In this sense, do you think we are like a computer? Yes + we have intelligence CPU - Central processing unit ALU - Arithmetic and logic unit ROM - Read only memory RAM - Random access memory

Computer Software Operating System - Provides an interface with the user unix, windows, linux, ... Software Tools word processors (MicrosoftWord, WordPerfect, ...) spreadsheet programs (Excel, Lotus1-2-3, ...) mathematical computation tools (MATLAB, Mathematica, ...) Computer Languages machine language assembly language binary language high level languages (C, C++, Ada, Fortran, Basic, java) WE WILL STUDY C PROGRAMMING LANGUAGE General purpose, machine-independent language Developed at Bell Labs in 1972 by Dennis Ritchie American National Standards Institute(ANSI) approved ANSI C standard in 1989

Executing a Computer Program Compiler Converts source program to object program Linker Converts object program to executable program

Some Key Terms and Software Life-Cycle Phases Source Program printable/Readable Program file Object Program nonprintable machine readable file Executable Program nonprintable executable code Syntax errors reported by the compiler Linker errors reported by the linker Execution/Run-time errors reported by the operating system

PROBLEM SOLVING Very Important

Ch 1.3 Problem Solving Methodology (must read) 1. State the problem clearly 2. Describe the input/output information 3. Work the problem by hand, give example 4. Develop a solution (Algorithm Development) and Convert it to a program (C program) 5. Test the solution with a variety of data

Example 1 1. Problem statement Compute the straight line (x1,y1) (x2, y2) 1. Problem statement Compute the straight line distance between two points in a plane 2. Input/output description Point 1 (x1, y1) Distance between two points (distance) Point 2 (x2, y2)

Example 1 (cont’d) 3. Hand example side1 = 4 - 1 = 3 side2 = 7 - 5 = 2

Example 1 (cont’d) 4. Algorithm development and coding a. Generalize the hand solution and list/outline the necessary operations step-by-step Give specific values for point1 (x1, y1) and point2 (x2, y2) Compute side1=x2-x1 and side2=y2-y1 Compute Print distance b. Convert the above outlined solution to a program using any language you want (see next slide for C imp.)

Example 1 (cont’d)

Example 1 (cont’d) 5. Testing After compiling your program, run it and see if it gives the correct result. Your program should print out The distance between two points is 3.61 If not, what will you do?

Modification to Example 1 How will you find the distance between two other points (2,5) and (10,8)? x1=2, y1=5, x2=10, y2=8,

Few Issues We will study the details of this program and C language later… The programming language is not the main part of problem solving! Main part is to figure out the necessary steps and their orders (if you can develop solution then coding is easy) For the same problem, we may come up with different and yet correct solutions. Computers cannot think or develop a solution, they just follow your instructions and do the operations faster Then how do computers do many things? Even play a game, for example chess?

Simple examples to develop solutions

Compute the area of a triangle State problem I/O Hand example Develop solution and Coding Testing x=3 cm y=4 cm area x y area = ½ * 3 *4 = 6 cm2 Get values of x and y Compute area = ½*x*y Print area

Given two complex numbers z1=a1+b1*i and z2=a2+b2*i, find z3= z1+z2 State problem I/O Hand example Develop solution and Coding Testing Get a1 b1 a2 b2 Compute a3 = a1 + a2 Compute b3 = b1 + b2 Print z3 = a3 + b3 * i

Given the number of seconds, find number of hours, minutes and seconds total_sec M S State problem I/O Hand example Develop solution and Coding Testing 3675 seconds can be written as 1 hour 1 min 15 sec Get total_sec H = total_sec / 3600 (integer division) M = (total_sec – (H*3600)) / 60 M = (total_sec mod 3600) / 60 S = total_sec – (H*3600) – (M*60) Print H hour, M min, S sec

A little bit difficult examples to develop solutions Some problems are from How to Solve it: Modern Heuristics by Michalewicz and Fogel. Springer 2004.

Example: Average speed Suppose a car goes from city A to city B with speed of 40 mph and immediately comes back with the speed of 60 mph. What is the average speed? Can you generalize this solution and outline step by step to find average speed when the speed from A to B is X and the speed from B to A is Y?

Quiz: Dimensions of a rectangle ranch? A farmer has a rectangular ranch with a perimeter of P=110 meters and an area of A=200 square meters. What are the dimensions of his ranch? What are the dimensions for any P and A? y x

Example: Make a triangle with maximum area Suppose you have a stick with the length of L meters. You want to divide it into three pieces with the length of x, y, and z meters, and make a triangle Find x, y, z such that the area of that triangle is maximum. L x y z

Example: Climbing a wooden post A snail is climbing a wooden post that is H=10 meters high. During the day, it climbs U=5 meters up. During the night, it falls asleep and slides down D=4 meters. How many days will it take the snail to climb the top of the post? Given that H > U > D. Can you generalize your solution for any H, U, and D?

Minimum number of coins Suppose you want to give x=67 cents to a person, what is the minimum number of coins You have many 25, 10, 5, 1 cents

Example: Assign letter grades Suppose I have your grades as follows name final midterm avg_hw quizze letter aaaa 30 20 30 4 ? bbbb 20 15 40 10 ? … How can I assign letter grades?

Example: Sum of numbers Given n (for example n=1000), compute sum = 1+2+3+…+n sum_odd =1+3+5+7+…+(2n+1) ln2=1- 1/2 + 1/3 - 1/4 +…  1/n

If you want this course to be easy, you must learn how to act like a computer  Develop necessary step-by-step instructions to perform the following real-life tasks like a computer Driving a car Following a direction to find an address Cook something Search a word in a dictionary Make a phone call Now, its your turn to think of a problem and give STEP-BY-STEP instructions… For the same problem, we may have different and yet correct solutions. So, …

Ten heuristics for problem solving How to Solve it: Modern Heuristics by Michalewicz and Fogel. Springer 2004. Don’t rush to give an answer, think about it Concentrate on the essentials and don’t worry about the noise (tiny details) Sometimes finding a solution can be really easy (common sense), don’t make it harder on yourself Beware of obvious solutions. They might be wrong Don’t be misled by previous experience

Ten heuristics for problem solving How to Solve it: Modern Heuristics by Michalewicz and Fogel. Springer 2004. Start solving. Don’t say “I don’t know how” Most people don’t plan to fail, they just fail to plan! Don’t limit yourself to the search space that is defined by the problem. Expand your horizon Constraints can be helpful to focus on the problem at the hand Don’t be satisfied with finding a solution, look for better ones Be patient. Be persistent!

A Checklist for Engineering Reasoning http://www. criticalthinking 1. All engineering reasoning expresses a purpose. Take time to state your purpose clearly. Distinguish your purpose from related purposes. Check periodically to be sure you are still on target. Choose realistic and achievable purposes.

2. All engineering reasoning seeks to figure something out, to settle some question, solve some engineering problem. Take time to state the question at issue clearly and precisely. Express the question in several ways to clarify its meaning and scope. Break the question into sub-questions. Determine if the question has one right answer, or requires reasoning from more than one hypothesis or point of view.

3. All engineering reasoning requires assumptions. Clearly identify your assumptions and determine whether they are justifiable. Consider how your assumptions are shaping your point of view. Consider the impact of alternative or unexpressed assumptions. Consider the impact of removing assumptions.

4. All engineering reasoning is done from some perspective or point of view. Identify your specific point of view. Consider the point of view of other stakeholders. Strive to be fair-minded in evaluating all relevant points of view.

5. All engineering reasoning is based on data, information, and evidence. Validate your data sources. Restrict your claims to those supported by the data. Search for data that opposes your position as well as alternative theories. Make sure that all data used is clear, accurate, and relevant to the question at issue. Make sure you have gathered sufficient data.

6. All engineering reasoning is expressed through, and shaped by, concepts and theories. Identify key concepts and explain them clearly. Consider alternative concepts or alternative definitions of concepts. Make sure you are using concepts and theories with care and precision.

7. All engineering reasoning entails inferences or interpretations by which we draw conclusions and give meaning to engineering work. Infer only what the data supports. Check inferences for their internal and external consistency. Identify assumptions that led you to your conclusions.

8. All engineering reasoning leads somewhere or has implications and consequences. Trace the implications and consequences that follow from your data and reasoning. Search for negative as well as positive implications (technical, social, environmental, financial, ethical). Consider all possible implications.