Lesson 1. Introduction to Programming OBJECTIVES

Similar documents
STUDENT OUTLINE. Lesson 8: Structured Programming, Control Structures, if-else Statements, Pseudocode

Midterms Save the Dates!

Last Time. University of British Columbia CPSC 111, Intro to Computation Alan J. Hu. Readings

C H A P T E R 1. Introduction to Computers and Programming

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

Chapter 8 Algorithms 1

Chapter 1. Introduction to Programming and Visual Basic Pearson Addison-Wesley. All rights reserved. Addison Wesley is an imprint of

2SKILL. Variables Lesson 6. Remembering numbers (and other stuff)...

Review. Input, Processing and Output. Review. Review. Designing a Program. Typical Software Development cycle. Bonita Sharif

SME1013 PROGRAMMING FOR ENGINEERS

Welcome to Starting Out with Programming Logic and Design, Third Edition.

Grade 6 Math Circles November 6 & Relations, Functions, and Morphisms

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

Flow of Control: Loops

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

1) What is the first step of the system development life cycle (SDLC)? A) Design B) Analysis C) Problem and Opportunity Identification D) Development

COMP163. Introduction to Computer Programming. Introduction and Overview of the Hardware

Steps to program development

SKILL AREA 304: Review Programming Language Concept. Computer Programming (YPG)

Computing and compilers

Topic 1: Programming concepts

Intro to Programming. Unit 7. What is Programming? What is Programming? Intro to Programming

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

COPYRIGHTED MATERIAL. An Introduction to Computers That Will Actually Help You in Life. Chapter 1. Memory: Not Exactly 0s and 1s. Memory Organization

CS187 - Science Gateway Seminar for CS and Math

Pseudo Code and Flow Charts. Chapter 1 Lesson 2

Why Study Assembly Language?

Visual Basic. Chapter 3

Introduction to C Programming

Chapter 1: Introduction to Computers and Programming

Appendix A: Objectives and Courseware Locations

Laboratory. Low-Level. Languages. Objective. References. Study simple machine language and assembly language programs.

Chapter 1 - An Introduction to Computers and Problem Solving

(I m not printing out these notes! Take your own.)

Curriculum Map Grade(s): Subject: AP Computer Science

8 Algorithms 8.1. Foundations of Computer Science Cengage Learning

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

12B. Laboratory. Databases. Objective. References. Write simple SQL queries using the Simple SQL applet.

Working with JavaScript

RESPONSIVE WEB DESIGN IN 24 HOURS, SAMS TEACH YOURSELF BY JENNIFER KYRNIN

Python - Week 1. Mohammad Shokoohi-Yekta

Flow of Control: Loops. Chapter 4

Fundamentals of Programming Session 1

Programming for Engineers in Python

Activity Guide - Will it Crash?

(0) introduction to the course. how to learn a programming language. (0) course structure

LESSON 2 VARIABLES, OPERATORS, EXPRESSIONS, AND USER INPUT

An Introduction to Python (TEJ3M & TEJ4M)

CSCI341. Lecture 22, MIPS Programming: Directives, Linkers, Loaders, Memory

Algorithms. Chapter 8. Objectives After studying this chapter, students should be able to:

Chapter 7: Javascript: Control Statements. Background and Terminology. Background and Terminology. Background and Terminology

Pull Lecture Materials and Open PollEv. Poll Everywhere: pollev.com/comp110. Lecture 12. else-if and while loops. Once in a while

CSI32 Object-Oriented Programming

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

Chapter 1. Introduction to Computers and Java Objects. Background information. » important regardless of programming language. Introduction to Java

Chapter 2: Input, Processing, and Output

Variables and Data Representation

STUDENT LESSON A5 Designing and Using Classes

Computer Programming-1 CSC 111. Chapter 1 : Introduction

CHAPTER 2.1 CONTROL STRUCTURES (SELECTION) Dr. Shady Yehia Elmashad

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

EKT 120/4 Computer Programming KOLEJ UNIVERSITI KEJURUTERAAN UTARA MALAYSIA

Adding content to your Blackboard 9.1 class

CSE 351. GDB Introduction

Developing Algorithms

VARIABLES. Aim Understanding how computer programs store values, and how they are accessed and used in computer programs.

Chapter 1: Introduction to Computers and Java

5 The Control Structure Diagram (CSD)

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

4. Java language basics: Function. Minhaeng Lee

Notes By: Shailesh Bdr. Pandey, TA, Computer Engineering Department, Nepal Engineering College

Chapter 1: An Overview of Computers and Logic

DCS/100: Procedural Programming

CS150 Introduction to Computer Science 1. What is CS150? Who Are We? CS150 is a programming course You will learn

Properties and Definitions

PROBLEM SOLVING AND OFFICE AUTOMATION. A Program consists of a series of instruction that a computer processes to perform the required operation.

Chapter 1 Lab Algorithms, Errors, and Testing

LABORATORY. 16 Databases OBJECTIVE REFERENCES. Write simple SQL queries using the Simple SQL app.

Programming Logic - Beginning

Objective: Analyze and classify triangles based on side length, angle measure or both.

printf( Please enter another number: ); scanf( %d, &num2);

Creating a Box-and-Whisker Graph in Excel: Step One: Step Two:

CSC172 Lab: State Space Search

Contents. Slide Set 1. About these slides. Outline of Slide Set 1. Typographical conventions: Italics. Typographical conventions. About these slides

C++ Programming Language Lecture 2 Problem Analysis and Solution Representation

Chapter 4: Writing and Designing a Complete Program. Programming Logic and Design, Third Edition Introductory

1. Allowed you to see the value of one or more variables, or 2. Indicated where you were in the execution of a program

Week 3. This is CS50. Harvard University. Fall Cheng Gong

Exercises: Instructions and Advice

SNS COLLEGE OF ENGINEERING

CSCI 1100L: Topics in Computing Lab Lab 11: Programming with Scratch

OHIO ASSESSMENTS FOR EDUCATORS (OAE) FIELD 010: COMPUTER INFORMATION SCIENCE

depicts pictorially schematic representation of an algorithm document algorithms. used in designing or documenting

Introduction to Programming

Thus needs to be a consistent method of representing negative numbers in binary computer arithmetic operations.

CS 150 Introduction to Computer Science 1. August 31, 2009

6.170 Laboratory in Software Engineering Java Style Guide. Overview. Descriptive names. Consistent indentation and spacing. Page 1 of 5.

COMP-202: Foundations of Programming. Lecture 2: Java basics and our first Java program! Jackie Cheung, Winter 2016

Computer Science 62 Lab 8

Chapter 1 Introduction to Computers

Transcription:

Introduction to Programming If you re new to programming, you might be intimidated by code and flowcharts. You might even wonder how you ll ever understand them. This lesson offers some basic ideas and programming examples with which you can follow along. You ll soon understand the logic behind software programs. In your first assignment, you ll read an introduction to computers and programming. In the second assignment, you ll learn the steps in creating a program. In the third assignment, you ll learn about modules and the best practices for creating a software program. OBJECTIVES When you complete this lesson, you ll be able to n Describe basic programming concepts and steps n Declare variables n Describe documentation n Discuss the importance of structure n Create modules n Pass arguments n Describe global variables and constants This study guide is designed to break down the material into easy-to-understand chunks so that you aren t intimidated by the material. Follow the directions outlined in the assignments, read the assigned text, and answer the questions to get the most from this course. You ll soon understand the basics of programming. Lesson 1 7

ASSIGNMENT 1: AN OVERVIEW OF COMPUTERS AND PROGRAMMING Read this assignment, and then read pages 1 26 in your textbook. When you re comfortable with the material presented in the text, answer the review questions in the textbook and complete the assigned exercises to gauge your progress. If there are any areas with which you don t feel comfortable, reread those sections in the textbook before returning to the study guide. When you feel you ve mastered the material in Chapter 1, move on to the next assignment. Note: Make sure to answer the checkpoints in the textbook as you read along. Check your answers in Appendix D, which is located on a PDF file on the CD included at the back of your textbook. Computers are a big part of people s lives today, but what makes them capable of doing such powerful tasks? The answer is that they re programmed to perform tasks, or what someone tells them to do. A program is a set of instructions for the computer to follow; programs are often referred to as software. Someone who creates programs or software is known as a programmer or software developer. Hardware refers to the physical parts of a computer. You ll read examples of different types of hardware, such as memory, a central processing unit (CPU), storage devices, input devices, and output devices. A computer needs both hardware and software to perform its four major functions: input, processing, output, and storage. Programmers tell the computer what to do by using programming languages, such as Visual Basic and C#. The programming language must follow certain rules, called syntax, for it to be understood. The commands that tell the computer what to do also must follow a certain sequence, or logic, so the computer can process the request. Computers store data in bytes, which are tiny storage locations. Each byte is divided into eight smaller units called bits. These bits act like switches because they re either on or off. When bits represent numbers, or binary numbers, 8 Introduction to Programming

they re assigned the number 0 when off and 1 when on. You ll read more about how numbers and characters are stored in this chapter. Machines understand machine language, which is difficult for people to communicate in. Therefore, program languages that instruct computers on what to do have been created. Types of programming languages include C, C++, Java, JavaScript, and Visual Basic, as well as several more. These are known as high-level languages. Programmers write statements known as source code. High-level languages need to be translated into machine language. A program that handles this translation is called a compiler. After programs are created, they re store on a storage device, such as a disk drive. When the CPU runs, or executes, a program, it follows three steps: 1. Fetch 2. Decode 3. Execute Lastly, you ll read about types of software. System software manages computer operations and includes operating systems and software development tools. Application software is used for tasks, which include word processing, e-mail, and spreadsheets. Now, answer the review questions at the end of Chapter 1, then complete Exercises 1 4 on page 26 of your textbook. Log in to your Student Area at http://www.pennfoster.edu. Go to My Courses and look for the Solutions link associated with this course. After you complete the review questions and exercises, move on to the next assignment. Lesson 1 9

ASSIGNMENT 2: INPUT, PROCESSING, AND OUTPUT Read this assignment, and then read pages 27 78 in your textbook. When you re comfortable with the material presented in the text, answer the review questions in the textbook and complete the assigned exercises to gauge your progress. If there are any areas with which you don t feel comfortable, reread those sections in the textbook before returning to the study guide. When you feel you ve mastered the material in Chapter 2, move on to the next assignment. Note: Make sure to answer the checkpoints in the textbook as you read along. Check your answers in Appendix D, which is located on a PDF file on the CD included at the back of your textbook. 1. Design the program. 2. Write the code. 3. Correct all syntax errors. 4. Test the executable code. 5. Debug the program. FIGURE 1 Steps of Program Creation Programmers perform five steps when creating a program (Figure 1). Syntax is the programming language s rules. Debugging refers to fixing any errors in the code so the program will work correctly. You ll read about each of these steps in greater detail in this chapter. When planning the logic of a program, programmers will often use flowcharts or pseudocode. A flowchart is a pictorial representation of the steps in a program. Pseudocode is an English-like representation of the steps. See Appendix B and Appendix C in your textbook for more information on flowcharts and pseudocode. Computer programs work by following these three steps: 1. Receive input (data) 2. Perform a process 3. Produce output (such as displaying information or performing a task) Program code can become quite complicated. When a collection of program statements becomes difficult to read, it s called spaghetti code because it s like following a noodle in a bowl of 10 Introduction to Programming

spaghetti. Therefore, keep your code simple by using structures. A sequence is one kind of structure (Figure 2). You can stack structures on each other at entrance or exit points. Putting one structure within another is called nesting. Programmers create variables that stand for different values. The name of a variable should be no more than one word. Programmers end programs by creating a decision, which is represented in a flowchart by a diamond. If the flowchart runs onto another page, they use a connector. When assigning values to variables, programmers often use the equal sign (=). Many programs require some sort of calculation to be performed, such as addition or multiplication. In this chapter, you ll read about these and other common math operations, as well as the order of operations. In most programs, variables must be declared before they can be used. This means that you must name the memory location and specify the type of data. Variable names are usually nouns, such as payrate, and types are the type of data the variable will hold (numbers or letters, for example). Two types of documentation are generated during the programming process. Internal program documentation is for the programmer and includes program comments that identify the logic of the program. External documentation is for the people who use your programs the end users who will need documentation to know how to use your program. This type of documentation is also called user documentation. Now, answer the review questions at the end of Chapter 2. In addition, complete the following exercises at the end of the chapter: n Algorithm Workbench 1, 5, and 11 n Debugging Exercises 1 and 2 n Programming Exercises 1 and 7 FIGURE 2 A Sequence Lesson 1 11