CSCE150A. Administrivia. Overview. Hardware. Software. Example. Program. Pseudocode. Flowchart. Control Structures. Hello World Program CSCE150A

Similar documents
Computer Science & Engineering 150A Problem Solving Using Computers

Problem Solving and Program Design - Chapter 1. Cory L. Strope

Computer is an electronic machine that can receive, store, transform and output data of all kinds (image, text, numeric, graphics and sound).

Chapter 1: Why Program? Computers and Programming. Why Program?

Chapter 1: An Overview of Computers and Programming Languages. Objectives. Objectives (cont d.) Introduction

Chapter 1: Why Program? Main Hardware Component Categories 8/23/2014. Main Hardware Component Categories: Why Program?

Programming 1. Lecture 1 COP 3014 Fall August 28, 2017

Chapter 1: Introduction to Computers and Programming

Introduction to Basis and Practice in Programming

Introduction to Computers. Joslyn A. Smith

Week 1 Introduction to Computer and Algorithm (Part1) UniMAP Sem II 11/12 DKT121: Basic Computer Programming 1

The Programming Process Summer 2010 Margaret Reid-Miller

CHAPTER 1 Introduction to Computers and Java

Programming 1 - Honors

Zimmer CSCI /24/18. CHAPTER 1 Overview. COMPUTER Programmable devices that can store, retrieve, and process data.

Fundamentals of Programming (Python) Basic Concepts. Ali Taheri Sharif University of Technology Spring 2018

Chapter 1: Introduction to Computers and Java

8/23/2014. Chapter Topics. Introduction. Java History. Why Program? Java Applications and Applets. Chapter 1: Introduction to Computers and Java

BITG 1113: Introduction To Computers And Programming Language LECTURE 1 LECTURE 1 1

! Learn how to think like a computer scientist. ! Learn problem solving. ! Read and write code. ! Understand object oriented programming

Computer Fundamentals

Programming Fundamentals (CS 302 ) Dr. Ihsan Ullah. Lecturer Department of Computer Science & IT University of Balochistan

Computer Basics 1/6/16. Computer Organization. Computer systems consist of hardware and software.

Information Communications Technology (CE-ICT) 6 th Class

Fundamentals of Programming. Lecture 1: Introduction to C Programming

C++ Programming Language Lecture 1 Introduction

Chapter 1 Computer and Programming. By Zerihun Alemayehu

Java and Software Design

Basic Computer Programming for ISNE. Santi Phithakkitnukoon ผศ.ดร.ส นต พ ท กษ ก จน ก ร

Fundamentals of Programming Session 1

Elements of Computers and Programming Dr. William C. Bulko. What is a Computer?

CHAPTER 1: INTRODUCTION TO COMPUTERS AND PROGRAMMING. 1 Muhalim Mohamed Amin Faculty of

Week 0: Intro to Computers and Programming. 1.1 Why Program? 1.2 Computer Systems: Hardware and Software. Hardware Components

Fundamentals of Programming Session 1

COURSE OUTLINE & WEEK WISE BREAKAGE

SCSP Programming Technique C

0 Introduction: Computer systems and program development

Chapter 1 Introduction to Computers and Programming

Computer Basics 1/24/13. Computer Organization. Computer systems consist of hardware and software.

Lecture 1. A. Sahu and S. V. Rao. Indian Institute of Technology Guwahati

Chapter 1. Introduction to Computers and Programming. M hiwa ahmad aziz

CS240: Programming in C

An Overview of the Computer System. Kafui A. Prebbie 24

CSc 10200! Introduction to Computing. Lecture 1 Edgardo Molina Fall 2013 City College of New York

Welcome to Computer Organization and Design Logic CS 64: Computer Organization and Design Logic Lecture #1 Winter 2018

Computer Architecture. Fall Dongkun Shin, SKKU

Ms. Minerva A. Lagarde

Preview from Notesale.co.uk Page 6 of 52

Class List. Java Must Have. Class Goals. Class Goals. Schedule

ECS15, Lecture 10. Goals of this course 2/8/13. Mini-Review & Topic 3.2 Software. Today s agenda

What is the typical configuration of a computer sold today? 1-1

Topics. Hardware and Software. Introduction. Main Memory. The CPU 9/21/2014. Introduction to Computers and Programming

W1005 Intro to CS and Programming in MATLAB. Brief History of Compu?ng. Fall 2014 Instructor: Ilia Vovsha. hip://

Week 1 Introduction to Programming

14:332:331. Lecture 1

Chapter 1. Computer Technology Concept of Programming & Algorithm and Flow Charts

1) Which of the following is an example of a programming language? 1) A) Microsoft Word B) English C) HTML D) Java

Welcome to Solving Problems with Computers I

What is a computer? Units of Measurement. - A machine that: - Counts.

8/16/12. Computer Organization. Architecture. Computer Organization. Computer Basics

Electricity: Voltage. Gate: A signal enters the gate at a certain voltage. The gate performs operations on it, and sends it out was a new signal.

CMSC131. Hardware and Software. Hardware

CMSC131. Hardware and Software

CS 1713 Introduction to Computer Programming II Ch 0 Overview - Problem solving

CS2303 C14 Systems Programming Concepts. Bob Kinicki

Chris Riesbeck, Fall Introduction to Computer Systems

Chapter. Focus of the Course. Object-Oriented Software Development. program design, implementation, and testing

High-Performance Scientific Computing

card slots CPU socket Monitor Computer case houses CPU (Central Processing Unit), CPU central power supply, DVD drive, etc processing unit Keyboard

Introduction to Computer Systems

EKT 120/4 Computer Programming KOLEJ UNIVERSITI KEJURUTERAAN UTARA MALAYSIA

CS 220: Introduction to Parallel Computing. Beginning C. Lecture 2

Introduction to Java Programming

Introduction to Computer Systems

Week 2: Data and Output

Welcome to Computer Organization and Design Logic

Administration Computers Software Algorithms Programming Languages

Chapter 1 Introduction to Computers and C++ Programming

Downloaded from various sources on the NET

Chapter 1 & 2 Introduction to C Language

CSC180: Lecture 2. Wael Aboulsaadat.

CS 105 Review Questions #3

Computer Architecture 2/26/01 Lecture #

Computer Science & Engineering 150A Problem Solving Using Computers

Introduction to C Programming 計算機程式設計

Introduction. Arizona State University 1

Week One: Introduction A SHORT INTRODUCTION TO HARDWARE, SOFTWARE, AND ALGORITHM DEVELOPMENT

Programming 1. Lecture 1 COP 3014 Fall August 28, 2018

Laboratory 2: Programming Basics and Variables. Lecture notes: 1. A quick review of hello_comment.c 2. Some useful information

Outline. Introduction to Programming (in C++) Introduction. First program in C++ Programming examples

Management Information Systems OUTLINE OBJECTIVES. Information Systems: Computer Hardware. Dr. Shankar Sundaresan

Fundamentals of Programming (C)

Computer Principles and Components 1

TUTORIAL Describe the circumstances that would prompt you to use a microprocessorbased design solution instead of a hard-wired IC logic design.

Engineering Computing M1H Together Towards A Green Environment

Computer ANAMIKA ACADEMY. Mo Which function has the ability to move from one web page to another Hyper link

ENT 189: COMPUTER PROGRAMMING. H/P: Home page:

Terminology, Types of Computers & Computer Hardware

Lecture 1: Preliminaries

Basic Concepts COE 205. Computer Organization and Assembly Language Dr. Aiman El-Maleh

Transcription:

Computer Science & Engineering 150A Problem Solving Using Computers Lecture 01 - Course Introduction Stephen Scott (Adapted from Christopher M. Bourke) Roll Syllabus Course Webpage: http://cse.unl.edu/~sscott/teach/classes/cse150af09/ Prerequisite test/placement test: http://ncite.unl.edu/cs_placement/ CSE: UNIX, logging in, usage agreement, CodeLab Lab Fall 2009 1 / 43 2 / 43 sscott@cse.unl.edu Intro CSCE Courses of Computers and ming 3 / 43 CSCE 101: Fundamentals of Computing (Alice) gives a breadth-oriented overview of the field of computer science. CSCE 150A: Introduction to Problem Solving with Computers (C) teaches fundamentals of problem solving via programming. CSCE 150E: Introduction to Computer ming for Scientists and Engineers (Fortran or Matlab) teaches fundamentals of problem solving via programming. CSCE 150M: Multimedia Approach to Computing (Python) teaches fundamentals of problem solving via programming. CSCE 155: Computer Science I (Java) is the first course towards the major or minor in CS. For those who pass 150 or score well on the Placement Exam: http://ncite.unl.edu/cs_placement/ CSCE 156: Computer Science II (C++) is the second course towards the major or minor in CS. 4 / 43 Computer Computer Development (Problem Solving) Introduction to Computers Different Types of Computers I Computers receive, store, process, and output information. Computers can deal with numbers, text, images, graphics, and sound, to name a few. Computers are useless without programming. ming languages allow us to write programs and thus communicate with computers. It takes our code and converts it into a format so the computer can understand it. Embedded Systems: ipod, cell phones, etc. Personal Computers: used by everyday people and typically used by just one person at a time Mainframes: used for real-time systems, ATMs, and such; very powerful and reliable computers Supercomputers: used by research laboratories for computationally intensive applications such as weather forecasting; the largest capacity and fastest mainframes Often configured as a cluster of several smaller computers 5 / 43 6 / 43

Different Types of Computers II vs. Figure: PrairieFire is a 98-node Beowulf cluster, originally constructed in 2002. It originally scored an HPL benchmark number of 442.50 GFlops, which was then the 107th most powerful supercomputer in the world, according to the TOP500 supercomputer list. See http://rcf.unl.edu/prairiefire/index.php is the equipment used to perform the necessary computations. E.g. CPU, monitor, keyboard, mouse, printer, etc. is the programs that enable us to solve problems with a computers by providing it with a list of instructions to follow. s: Word, Firefox, games, etc. Firmware - small programs stored in non-volatile memory 7 / 43 8 / 43 Computer Memory I Main Memory RAM - Random Access Memory - Memory that can be accessed in any order ROM - Read Only Memory - Memory that cannot be written to Secondary Memory - Hard disks, flash drives, CDs, DVDs, etc. Central Processing Unit (CPU) - Coordinating all computer operations and perform arithmetic and logical operations Input/Output Devices - Monitor, printer, keyboard, & mouse Computer Networks (not hardware, but configuration of the hardware) - WAN, LAN, MAN, Wireless LAN Memory is an essential component in any computer. Memory Cell - the storage location Address - the location of the memory cell relative to other memory cells Content - what is stored in the memory cell All programs run in memory Every memory cell has content, whether we know it or not. So always initialize variables 9 / 43 10 / 43 Memory II Memory III Address Contents 0-27.2 1 42 2 0.005 3-26 4 H.. 998 x 999 75.62 Figure: Portion of Memory Cells bit - deriving from binary digit, is either a 0 or 1 byte - a memory cell is actually a grouping of smaller units called bytes. A byte is made up of 8 bits : A single character, H requires a byte to store kilobyte: 1024 bytes (not 1000 bytes) In general, memory sizes are powers of two, 2 10 = 1024 is the power of two closest to 1, 000 megabyte: 2 20 = 1, 048, 576 bytes (or 1024 kilobytes) gigabyte: 2 30 = 1, 073, 741, 824 bytes (or 1024 megabytes) kilo-, mega-, giga- may refer to bytes in base-10 in some contexts (network data) or when discussing bits 11 / 43 12 / 43

Memory Exercise Memory Exercise Problem A certain portable MP3 player is advertised as a having a 30GB hard drive. In reality, it has 30, 000, 000, 000 bytes. How many actual (base-2) gigabytes does it have? Problem A certain portable MP3 player is advertised as a having a 30GB hard drive. In reality, it has 30, 000, 000, 000 bytes. How many actual (base-2) gigabytes does it have? Divide by the number of bytes in a gigabyte: 13 / 43 13 / 43 Memory Exercise Memory Exercise Problem A certain portable MP3 player is advertised as a having a 30GB hard drive. In reality, it has 30, 000, 000, 000 bytes. How many actual (base-2) gigabytes does it have? Problem A certain portable MP3 player is advertised as a having a 30GB hard drive. In reality, it has 30, 000, 000, 000 bytes. How many actual (base-2) gigabytes does it have? Divide by the number of bytes in a gigabyte: Divide by the number of bytes in a gigabyte: 30, 000, 000, 000 bytes 1024 1024 1024 bytes-per-gigabyte 30, 000, 000, 000 bytes 1024 1024 1024 bytes-per-gigabyte = 27.93GB 13 / 43 13 / 43 Computer I Computer II Operating System - controls the interaction between machine and user Communicate with user Manage memory Collect input/display output Read/write data Figure: OS/device interaction 14 / 43 15 / 43

Computer III Computer Languages Application - developed to assist a computer use in accomplishing specific tasks (e.g. Word, Excel, Safari, etc.) Machine Language - A collection of binary numbers Machine language is not standardized, and will vary between families of processors, such as Intel (x86) and Macintosh ML bits directly control the electronic circuits Assembly Language - mnemonic codes rather than binary Low-level language - A language that is close to the hardware High-level Languages - combine algebraic expressions and symbols from English High-level language (HLL) - Closer to human language, easier to read, write, and maintain Must be translated to Machine language Independent from the hardware E.g. Fortran, Cobol, Lisp, C, Prolog, Pascal, C#, Java 16 / 43 17 / 43 Computer Languages s of Different Levels of Computer Languages 18 / 43 Figure: Language Hierarchy 19 / 43 Figure: s of Languages Compiling Code Compiler Compiling is the process of taking your source code and turning it into executable code Source file - A file containing the program code A compiler turns the source file into an object file Object file - a file containing machine language instructions A Linker turns the object file into an executable Integrated Development Environment (IDE) - a program that combines simple word processing with a compiler, linker, and loader 20 / 43 21 / 43 Figure: Compiling Process

Development Method Steps Defined Specify the problem requirements Analyze the problem Design the algorithm to solve the problem Implement the algorithm Test and verify the completed program Maintain and update the program Problem - specifying the problem requirements forces you to better understand the problem Analysis - analyzing the problem involves identifying the problem s inputs, outputs, and additional requirements Design - designing the algorithm to solve the problem requires you to develop a list of steps that solve the problem and verify the steps Implementation - implementing is writing the algorithm as a program Testing - testing accuracy of the program Maintenance - maintaining involves finding previously undetected errors and update the program to code Problems and setbacks are part of the process. 22 / 43 23 / 43 : Converting Miles to Kilometers Miles to Kilometer Conversion Problem - convert miles to kilometers Analysis Input: Number of miles, Output: Number of kilometers, Relevant info: 1 mile = 1.609 kilometers Design: 1 Get distance in miles 2 Convert to kilometers 3 Display kilometers 1 # include <stdio.h> 2 int main ( void ) 3 { 4 double miles, kilometers ; 5 printf (" How many miles do you have?"); 6 7 scanf ("%lf",& miles ); 8 9 kilometers = miles * 1.609; 10 printf (" You have %f kilometers \n",kilometers ); 11 12 return 0; 13 } 24 / 43 25 / 43 Testing We need to test the previous program to make sure it works. To test we run our program and enter different values and make sure the output is correct. Algorithm - A list of steps for solving a problem; can be represented as pseudocode or as a flowchart - A combination of English phrases and C constructs to describe algorithm steps - A diagram that shows the step-by-step execution of a control structure Less commonly used than pseudocode, but gives you a visual feel for the flow of the program 26 / 43 27 / 43

of is simply an outline of a program Cannot be compiled nor executed There are no formatting or syntax rules The benefit of pseudocode is that it enables the programmer to concentrate on the algorithms without worrying about the syntactic details of a particular programming language. In fact, You can write pseudocode without even knowing what programming language you will use for the final implementation M2KM: 1 Input Miles 2 kilometers = 1.609 miles 3 Output kilometers Problem - How do I compute my grade for this course? Specify the problem - get the scores for elements of the course and compute the final grade Analyze the problem - we need to input the scores and percentage for each part of the course and output the grade Design - 1 Get the scores for homeworks, quizzes, exams, learning objects, and lab 2 FinalScore = homework * 0.35 + quizzes * 0.10 + midterm * 0.1 + final * 0.15 + lab * 0.25 + learningobjects * 0.05 3 Output FinalScore Implement - We can implement after we learn how to program 28 / 43 29 / 43 of 30 / 43 Figure: objects 31 / 43 Figure: : ATM Seven Sequential Structure: A method for controlling the order in which instructions execute In C, there are 7 control structures 1 Sequential 2 If-Then 3 If-Then-Else 4 Switch 5 For-Do 6 While-Do 7 Do-While Use a sequential structure whenever program statements follow one after the another with no decisions and no repetitions Processing flow is always downward from top to bottom in sequential structures Figure: Sequence 32 / 43 33 / 43

If Then If Then Else Use the If-Then structure when there is a single process to do or not do Processing flow is down either the left side or the right side A conditional is checked. If it is true then the action is performed If the conditional is false then the action is not performed and the flow continues Figure: If Then Figure: If Then Else Use If Then Else when one of two processes must be chosen Processing flow is down either the left side or the right side Similar to the If-Else, a conditional is checked, but some action is performed in either event 34 / 43 35 / 43 Switch For-Do 36 / 43 Whenever there are multiple potential options depending on a single values, use the switch statement : Multiple If-Then-Else statements If a conditional can match several possibilities, then a different action must be chosen for each possibility Figure: Switch 37 / 43 Figure: For-Do Use For-Do when you need to repeat an action multiple times, and you know how many times you will repeat it Also known as a For Loop A specific action or actions are executed for as many times as are specified Must know the number of times to be executed up front (though may still be variable: n) While-Do Do-While Use While-Do when the number of loops is unknown and process might not be executed at all (indeterminate pre-test) A conditional is checked before each execution to see if the loop should continue or end Each time the loop executes, (hopefully) progress is made toward its terminating condition Do-While: similar to While-Do, but the action is executed at least once unconditionally Conditional can be seen as being checked at the end of the loop Difference is subtle but important Figure: Do-While Figure: While-Do 38 / 43 39 / 43

Which Structure to Use Questions Questions? 40 / 43 Figure: to decide which type of control 41 / 43 Your First Your first program: 1 Edit code using your favorite text editor (pico, emacs, gvim (tip: use gvim Easy), etc.) 2 Save code to a file, helloworld.c 3 CSE command line: use gcc to compile into an executable file, a.out 4 Run program by calling a.out 5 More details in lab 1 # include < stdlib.h> 2 # include < stdio.h> 3 4 int main ( int argc, char * argv []) 5 { 6 printf ("!\n"); 7 return 0; 8 } 42 / 43 43 / 43