Introduction to Computers and Programming

Slides:



Advertisements
Similar presentations
ICS103 Programming in C Lecture 1: Overview of Computers & Programming
Advertisements

Lecture 1: Overview of Computers & Programming
 Computer hardware components are the physical pieces of the computer.  The major hardware components of a computer are: – The central processing.
Chapter 1 - An Introduction to Computers and Problem Solving
Starting Out with C++, 3 rd Edition 1 Chapter 1. Introduction to Computers and Programming.
COSC 120 Computer Programming
Introduction to Computer Systems
Copyright © 2012 Pearson Education, Inc. Chapter 1: Introduction to Computers and Programming.
Copyright © 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Starting Out with C++ Early Objects Sixth Edition by Tony Gaddis, Judy Walters,
1 CS150 Introduction to Computer Science 1 Professor: Chadd Williams
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.
CS 0008 Day 2 1. Today Hardware and Software How computers store data How a program works Operators, types, input Print function Running the debugger.
CS102 Introduction to Computer Programming
Introduction to Computers and Python. What is a Computer? Computer- a device capable of performing computations and making logical decisions at speeds.
Copyright © 2012 Pearson Education, Inc. Chapter 1: Introduction to Computers and Programming.
The Study of Computer Science Chapter 0 Intro to Computer Science CS1510, Section 2.
Alternate Version of STARTING OUT WITH C++ 4 th Edition Chapter 1 Introduction to Computers and Programming.
Why Program? Computer – programmable machine designed to follow instructions Program – instructions in computer memory to make it do something Programmer.
Chapter Introduction to Computers and Programming 1.
TERMS TO KNOW. Programming Language A vocabulary and set of grammatical rules for instructing a computer to perform specific tasks. Each language has.
Introduction to Programming Dr Masitah Ghazali Programming Techniques I SCJ1013.
CSC 125 Introduction to C++ Programming Chapter 1 Introduction to Computers and Programming.
CSE 1340 Introduction to Computing Concepts Class 2.
Chapter 3 Computer Hard ware
INTRODUCTION TO COMPUTER PROGRAMMING itc-314 LECTURE 01.
Topics Introduction Hardware and Software How Computers Store Data
Copyright © 2012 Pearson Education, Inc. Chapter 1: Introduction to Computers and Programming.
Chapter 1: Introduction to Computers and Programming.
Copyright © 2009 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 1: Introduction to Computers and Programming.
The Study of Computer Science Chapter 0 Intro to Computer Science CS1510.
Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Starting Out with C++ Early Objects Seventh Edition by Tony Gaddis, Judy.
Introduction to Computers
Introduction to Programming Using C Introduction to Computer Programming.
C++ Programming: From Problem Analysis to Program Design, Third Edition Chapter 1: An Overview of Computers and Programming Languages.
Computer Architecture
Module 2 : Part 1 INTRODUCTION TO HARDWARE & SOFTWARE INTRODUCTION TO HARDWARE & SOFTWARE.
SKILL AREA: 1.2 MAIN ELEMENTS OF A PERSONAL COMPUTER.
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.
Computer Programming (1) Code & No.: CS 102 CREDIT HOURS: 5 UNIT Lecture 3.0 hours/week Lab: 2.0 hour/on every week a. This course introduces the students.
Computer and Programming. Computer Basics: Outline Hardware and Memory Programs Programming Languages and Compilers.
Brief Version of Starting Out with C++ Chapter 1 Introduction to Computers and Programming.
©2013 Pearson Education, Inc. Upper Saddle River, NJ. All Rights Reserved. Introduction to Computers and Computing.
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.
Copyright © 2010 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 1: Introduction to Computers and Programming.
Victoria Ibarra Mat:  Generally, Computer hardware is divided into four main functional areas. These are:  Input devices Input devices  Output.
Programming Logic and Design Seventh Edition Chapter 1 An Overview of Computers and Programming.
Visual Basic Programming Introduction to Computers Programming.
Chapter 1: Introduction to Computers and Programming
Computer Systems Nat 4/5 Computing Science Computer Structure:
Java Programming: From the Ground Up
BASIC PROGRAMMING C SCP1103 (02)
Topics Introduction Hardware and Software How Computers Store Data
BASIC PROGRAMMING C SCP1103 (02)
DDC 1023 – Programming Technique
ICS103 Programming in C Lecture 1: Overview of Computers & Programming
Chapter 1: An Overview of Computers and Programming Languages
C++ Programming: From Problem Analysis to Program Design
Chapter 1: Introduction to Computers and Programming
The Study of Computer Science
Topics Introduction Hardware and Software How Computers Store Data
Components of a CPU AS Computing - F451.
The Study of Computer Science Chapter 0
ICS103 Programming in C 1: Overview of Computers And Programming
Programming Logic and Design Eighth Edition
Chapter 1: Introduction to Computers and Programming
Presentation transcript:

Introduction to Computers and Programming CS0007: Introduction to Computer Programming

Programming – Why? Computers are used for many different purposes in many different situations. But, how can they be so versatile? Answer: They can be programmed The ability for a computer to be programmed allows it to do whatever their programs tell them what to do. A program is a set of instructions that tell a computer what to do. A computer cannot do anything unless it has a program to tell it what to do. In this class, we will focus on writing these programs.

Programming – What? Programs are used to operate the components of a computer, solve problems or satisfy a want/need. How long will it take me to get home if I drive x miles per hour? I want to be able to tell my friends what I am doing right now. Computer Programming is both an Art and a Science Every aspect of a program must be carefully designed As an art, programming takes creativity and problem solving. There is often no one correct way to solve a problem. As a science, there are formal and proven methods to go about creating a programming. In this course, you will learn both the art and science of programming.

Hardware and Software Programs can also be called software. Software refers to the computer programs that a computer uses to complete a task. Hardware refers to the physical components that a computer is made of. A computer is not one device, but a system of devices working in tandem. Each device plays a part. Major components: Central Processing Unit Main Memory Secondary Storage Devices Input Devices Output Devices

Central Processing Unit (CPU) The CPU is the heart and brain of the computer. The CPU continuously does the following things: Fetch an instruction Follow the instruction Produce some resulting data The CPU has two parts: Control Unit Coordinates the computer’s operations Determines where to get the next instruction Regulates the other major components of the computer Arithmetic and Logic Unit (ALU) Designed to perform mathematical operations

Main Memory Main memory holds information that the CPU needs to access quickly. Namely, the instructions to be executed. When a program is running, some or all of its instructions are in main memory. Memory is divided into sections called bytes that hold equal amount of data. Each section is made up of 8 bits. A Bit is the most basic unit of information a computer can hold. It is a switch that is either on (1) or off (0) Each byte is assigned and can be accessed by its address. A Memory Address is a unique identifying number associated with a byte in memory. Main memory typically is volatile. Volatile Memory – is memory that when it loses power, the contents are erased.

Secondary Storage Secondary Storage is memory that can hold data for a long period of time. Programs are usually stored in secondary storage and loaded into main memory as needed. This forms a hierarchy typically called the memory hierarchy. Common forms of secondary storage: Hard Drive Disk Drive Solid State Drive Removable Storage Floppy Disk CD-ROM USB Drives Other files can be stored in secondary storage: Documents Pictures Whatever else you save on your computer

Input Devices Input is any data the computer collects from the outside world. An Input Device is anything that collects data and sends it to the computer. Common Input Devices: Keyboard Mouse Scanner Digital Camera Disk Drive USB Drive

Output Devices Output is any data the computer sends to the outside world. An Output Device formats data and presents it to the outside world. Common Output Devices: Monitor Printer Disk Drive USB Drive

Software Software refers to the programs that run on a computer. Two main categories (for this class): Operating System (OS) A set of programs that manages a computer’s hardware devices and controls their processes. Most modern operating systems are capable of running multiple programs at once. UNIX, Linux, Mac OS X, and Windows are examples Application Software Programs that make the computer useful for the user Solve specific problems or supply a service Word processors, spreadsheets, databases, etc. This is what we will be developing in this class.

Program Development Cycle Many programmers follow a sequence of Steps to create their programs. Analyze – Define the Problem Make sure that you understand what the program should do. What should the user be able to enter? How? How does the program come up with an answer? What does the program output? How? User – a person who uses a computer program. End User – the user that the program was made for. Design – Plan a Solution for the Problem Develop a PRECISE sequence of steps to solve the problem An algorithm is a precise sequence of steps to solve a problem.

Develop an Algorithm Imagine you want a program that tells a user how many stamps they need in order to mail a certain number of pages. You need one stamp for every 5 pages 6 pages = 2 stamps 12 pages = 3 stamps … Write an algorithm (the steps needed) to solve this problem

Program Development Cycle – Design (Continued) Typically a program follows three general steps Input Processing (Formulas) Output

Develop an Algorithm, 2nd Attempt OK, with this knowledge, try writing the algorithm again

Program Development Cycle – Design (Continued) Are those three steps enough? What about if the user enters “Banana” instead of a number of sheets? The program does not know how to find the number of stamps required to mail “Banana” number of sheets In order for the program to run without crashing, our algorithm must make sure that the user inputs some valid data. There are two main ways of doing this: Prevention – Making sure that the user is not physically able to enter in invalid data. Validation – Allowing the user to enter invalid data, but checking it to make sure it is valid before processing. So, there are really 4 general steps most programs follow: Input Read Input Validate Input Process Output

Develop an Algorithm, 3rd Attempt OK, now with THAT information, try developing the algorithm One good algorithm developed could look like this: Request the number of sheets of paper from the user; call it Sheets (Input/Read) Make sure Sheets is a positive whole number (Input/Validation) Divide Sheets by 5 (Processing) Round the result from step 3 up to the highest whole number; call it Stamps (Processing) Reply with the number Stamps (Output)

Programming Tools Flowcharts – A chart that consists of symbols connected by arrows. Within each symbol is a phrase presenting the activity at that step. The shape of the symbol indicates the type of operation that is to occur. Hierarchy Charts – A chart that shows the overall program structure. These charts describe what each part, or module, does and how they are related. These modules intentionally omit details of how they work. Pseudocode – an abbreviated plain English version of actual computer code. Kind of a mix between English and code. THERE IS NO OFFICIAL SYNTAX TO PSEUDOCODE.

Flow Charts Flow Line - indicates the flow of logic Terminal – indicates the start or end of a task Input/Output – used for input or output operations. What is to be input or output should be in the figure.

Flow Charts Processing - used to show a processing step. The instructions are displayed in the figure. Decision – used to show when a decision needs to be made. Lines for yes and no come out of it. The question is displayed in the figure. Connector – Used to join flow lines.

Stamps Flowchart Start Read Sheets No Yes Display Stamps End Is sheets a positive whole number? Display Error Message Set Stamps = Sheets/5 Round Stamps to nearest whole number Display Stamps End

Round Stamps to the next whole number Hierarchy Chart Postage Stamp Program Input Calculate Stamps Display Stamps Read Sheets Validate Sheets Set Stamps = Sheets/5 Round Stamps to the next whole number

Program Development Cycle Write the Code – Implement a solution The instructions in a programming language collectively called code. Your code should be a translation of your algorithm developed into the programming language. In this class we use Java, but there are many other programming languages: C, C++, C#, Ruby, Python, Visual Basic, etc. This is the major focus of this course, but note that you need to be able to think algorithmically in order to do this. Meaning, you need to be able to logically solve the problem in order to write a program for it.

Program Development Cycle Testing and Debugging – Locate and remove any errors in the program Testing is the process of finding errors in a program Debugging is the process of removing errors in a program. An error in a program is called a bug. We will talk more specifically about the kinds of errors that can occur in a program once we start programming. Complete All Documentation – Organize the material that describes the program. Documentation is any material whose purpose is to allow another person or programmer to use or understand the program Two kinds of documentation: External Documentation – Material outside of the code files that describe the program. Internal Documentation – Lines inside of a code file that do nothing except describe details of the program. In Java, these are called comments.