Chapter 1 - What s in a program?

Size: px
Start display at page:

Download "Chapter 1 - What s in a program?"

Transcription

1 Chapter 1 - What s in a program? I. Student Learning Outcomes (SLOs) a. You should be able to use Input-Process-Output charts to define basic processes in a programming module. b. You should be able to use a generic Screen design sheet to create screen design sequences for a programming project. c. You should be able to identify the basic components of a function and describe the importance of the main function. d. You should be able to write a program in C++ that prints phrases of your choice. II. Demonstration Program Here is a working program in C++. It was written using Microsoft s (MS) Visual Studio. It can be created using other compilers the only MS eccentricities are the use of the stdafx.h and the use of int _tmain(int argc, _TCHAR* argv[]). The #include "stdafx.h" can be commented out and int _tmain(int argc, _TCHAR* argv[]) can be replaced by int main ( void ). 1. //The following is a first program 2. //Using your editor type it in and 3. // see what happens 4. #include "stdafx.h" 5. #include <iostream> 6. using namespace std; 7. int _tmain(int argc, _TCHAR* argv[]) 8. { 9. cout << "Press <ENTER> to continue" << endl; 10. cin.get(); 11. return 0; 12. } Program 1.1 Output with interactive Input.

2 Line-by-Line Description 1. Comment which is noted by the // preceeding the text in the line. The comment is terminated by the end of the line. MS Visual Studio notes comments in green font color. 2. Another comment. 3. And another 4. This is a Preprocessor. Preprocessors are noted by the # symbol. This is an instruction to the compiler which is executed before any of your code is reviewed. In this case #include says that a file (or code) is to be incorporated into your project. Include is a Reserved Word. Reserved words can only be used in specific ways. MS notes reserved words with a blue color. Note the quote marks. The stdafx.h file is MS specific and may cause a compile error in other systems. This line can be commented out. If it is included, it MUST be the first include. 5. This is another #include but the quote marks are different they look like < >. The difference is the location of the file to look in. The means look in the current working directory in this case the hello directory (generally when we refer to project we really mean project directory, or just directory ). The < > indicates the file is located in a folder specified by the Integrated Development Environment (IDE) not in our working directory. MS uses the brown color to indicate a string (character sequence) constant. In both lines 4 and 5 the file names are brown. 6. In this line there are two reserved words using and namespace. Although somewhat beyond the scope of this course, a namespace is an organization mechanism for large files and allows you to selectively access components without loading the entire file. In this case we will be using the std component of the iostream header file. The std character sequence is in black. This indicates, other than being the assigned name to the namespace, it has no special meaning to the compiler. 7. This is the beginning of what we think of as the program. Actually it is the identification (name) given to the block of code that follows in lines 8 through 12. We will be more specific later. This sometimes is termed the function heading. The function is the

3 primary programming module in C and C++. The function heading is made up of 3 parts: return type, function identifier, and parameter list. a. Return type is the data type of the value created as a result of executing the function (in this case an integer). Note that int is a reserved word. b. Function Name is the identifier (name) we (the programmer) give the block of code (function). c. Parameter list is enclosed by parentheses ( ). The parameter list indicates the values required for the operation of the function. It includes the data type and identifier used to reference the data within the block of code. More about this later. 8. The opening brace ( { ) identifies the beginning of the block of programming (code). Notice the closing brace ( } ) in line 12. This is where the program (block of code) takes care of business. 9. This is the first executable line of code in our programming block. The first character sequence cout is linked to the default output device, the screen (console output). The next symbol is the insertion operator, <<. Its job is to insert the following stuff into the output stream, sending it to the specified device. The third component (in quotes) is the data that is to be inserted into the output stream and to be sent to the device, in this case - Press <ENTER> to continue. Once again we see the insertion operation operator. Then the final instruction, endl, means end of the line and sends a carriage return to the output device. The last character, the semi-colon ( ; ), terminates the line of executable code. We will see other lines of instruction that do not have semi-colons after them. These will be lines of control code. They will control other executable instructions. You can preview an example of these in the program sample for chapter This line of executable code (noted by the ending semi-colon) is actually an input instruction that we are using to tell the computer to wait for the enter key to be pressed to continue. The cin refers to the default input device, the keyboard (console input). The.get() is a component (member function) of cin that allows the program to

4 capture a single character. We are not doing anything with the character (for example assigning it to memory) just throwing it away. Your turn: After you have typed in the program above, compiled it and seen the results try the following modifications recompile and execute after each step. 1. Add a line of code above line 9 to output your name. 2. Add a line of code that puts a blank line between your name and the Press <ENTER> to Continue prompt. 3. Try modifications of your own (one line-at-a-time), compile, and execute. Now let s see what errors do to our output. 11. Remove a semi-colon from one of the lines of executable code and compile. Did you see the message window? Look at the first error message (sometimes the first two messages) it s the most important message. Sometimes you can get 20 or more messages for a single error. The first one or two messages are the most significate. In this case your error message might look something like the following depending on your compiler >c:\users\ed\documents\visual studio 2005\projects\hello\hello\hello.cpp(13) : error C2146: syntax error : missing ';' before identifier 'cin' The bold is my addition for emphasis. 12. Correct this error and create a different error. Get used to using and understanding the messaging system for your compiler. After seeing the actions with a single error, experiment with two errors. Just remember it is the first couple of messages that count

5 Program design First it is critical to understand how a program relates to the computer (via the compiler). Think of the computer as a very obedient 2-year old. You have to tell them exactly, step by step, how to do something. If the computer (compiler) doesn t understand, it throws a fit (error messages). If you make assumptions between steps the computer does not understand, and guess what ---? So what do you have to do? You have to think about how you are going to tell the computer how to do something this is called the design. A program has to be designed. One of my mentors once said, the sooner you get on the computer, the longer it takes. It was not until years later that I understood. The purpose of the design is two-fold: mostly for our benefit to remember what we were doing and to keep us on task, then to communicate our ideas to other folks. The two initial design tools we will consider is the Input-Process- Output (IPO) chart and the story board. 1. The IPO chart Programming modules (with a few exceptions) require some data to be available before anything can be done. An analogy You are a mathematical genious, you can add 7- digit numbers in your head. However no one has given you any numbers to add. How much work can you expect to accomplish? Nada ( nothing in Spanglish). Additionally, even if you have data it might not be what you need for a particular outcome. Another analogy You are that same mental giant and someone has given you a pile of numbers but they ask for the descriptions for the widgets in stock!!! What?? I can t do that with the data you gave me. The data is not appropriate for the needed outcome. How much work can be accomplished?

6 A third analogy Assume you have no idea as to how to add numbers for you 2 plus 2 is hyroglyphics. You are give a pile of numbers and are asked to generate a normal distribution of the values. What s that you say??? Once again it ain t happening. The moral here is that you (and the computer) have to have data to work with, have to have some attainable out come ( we can get there from here ), and we know how to do the work. We have input, know the process, and can create the desired output (I/P/O). I tend to create an IPO chart for every function (module) I create. My approach is to indicate the data that I have to work with and the desired output first. Then I work on the process. The process may have to be broken into multiple steps (eventually functions) to operate effectively. An IPO chart might look like Input (1 st ) Process (3 rd ) Output (2 nd ) List the data to work with The anticipated operations to be performed Expected outcome(s) 2. The story board Once we have an idea as to what we are going to do, the next step is to figure out what the screens might look like. The sequence of screen designs is the story board. I use a template that was created in Excel <refer to the class Resources page>. The following is a sample screen design sequence for an input screen (user prompts, etc.) and a design for displaying the resulting output. Because the user does not generally have anything to do with the processing, there is typically not screen design for the process (although not always).

7 Putting it altogether The following is a scenario that incorporates the use of an IPO chart and associated story board design for a program that prompts a user for a series of numbers, calculates an average, and displays the resulting output. I understand that this is probably over-kill for this kind of program but we are talking about a concept and an approach that will be useful as the projects get more substantial. I have added a third, splash screen design. The splash screen will act as an introduction to our program. As conceived, it is simply a series of output statements (cout) with a prompt and trap for the ENTER key (see above). IPO Input (1 st ) Process (3 rd ) Output (2 nd ) Prompt for each value Allow the user to enter the value Add each input value to a total For each value add 1 to a counter After all values are entered divide the total by the counter and assign Display the average The Database In the following sequence of chapters a data base design and development scenario will be followed. A number of different scenarios will be suggested in an appendix. Any of the scenarios can be developed in a similar manner. In real-time one would probably not follow the chapter sequence lock-step because in the text we are interested in using the development of a database project as an instructional tool also, presenting a number of techniques which may or may not be incorporated as the situation dictates.

8 The Database scenario (Employee Tracking System) The purpose of the employee tracking system is to keep track of employee data including contact information, date of hire, and position. The company has two categories of employees (for our purposes) managers and sales personnel. Additionally the company has an employment part-time status and a full-time status which are used to calculate pay rates. All data will be entered as dynamic strings (covered in the next chapter) and converted (as necessary) into numeric equivalents. The following data items will be required for each employee: Employee Number (key field) unique values Last Name First Name Address Zip Code Job Position (M/S) Job Status (F/P) Hours Worked Job Position and Job Status will be used to determine the pay rate of the individual employee. The pay rate will be multiplied by the number of hours worked to determine the total pay for this pay period. The pay rates are determined as indicated in the table below. The measure is in dollars per hour. Job Status Job Position Manager Sales Full Time Part Time At this point we are expected to generate an IPO chart, a splash screen design, input screen design, and an output screen design.

9 IPO Chart for the Employee Tracking System. Input (1 st ) Process (3 rd ) Output (2 nd ) Last Name First Name Address Zip Job Position Job Status Hours Worked (no processing) -> (no Processing) (no processing) (no processing) (no processing) (no processing) (no processing)-> Last Name First Name Address Zip Job Position Job Status Hours Worked Pay for the period The words No Processing do not normally appear. Typically you see an arrow passing through the Processing column. Samples of possible screen designs. Figure 1. Sample Splash Screen for the Employee Tracking System using the Excel template.

10 Figure2. Sample input screen for the Employee Tracking System. Figure 3. Sample output screen for the Employee Tracking System

11 Programming/design considerations and Tips 1. IPO chart make sure all input data is listed in the input column; all expected outcomes for this module are indicated in the output column; and all processes are indicated in the process column. 2. Screen design For this project you should be designing for a text screen with 25 rows and 80 characters (columns) in each row. Remember the computer prints from the upper left corner to the lower right corner, one row at a time (at this point no going back). a. Splash Screen try to use the whole screen. In the design template a single character can be in a cell of the worksheet. To quickly figure the center position (assuming a 80-character column) subtract the number of characters in your string from 80. Then divide the result by 2. If rounding is required, it does not really matter if you round up or down just be consistent. DO NOT bunch all of the presentation in the upper left corner of the screen. Include the project title, the developer(s), and other pertinent information. Provide a prompt for the user. b. Input Screen this is the first of the standardized screens. The necessary components are project title, screen title, user instructions, main presentation, user -prompt to continue. In this case the instructions appear after the screen title is printed in anticipation of the data prompts. It is not a good idea to automatically transition to the next screen after the last data item input. c. Output Screen is essentially the same as the input screen. This will be the same for all subsequent screens. The pay will be a result of multiplying the hours worked and the pay rate. The pay rate will be determined using nested if-else structures (discussed in the next chapter).

Chapter 2 - I know what I want to do NOW WHAT? Student Learning Outcomes (SLOs)

Chapter 2 - I know what I want to do NOW WHAT? Student Learning Outcomes (SLOs) Chapter 2 - I know what I want to do NOW WHAT? Student Learning Outcomes (SLOs) a. You should be able to list two significant characteristics for each of the basic data types (bool, int, double, and char).

More information

Program Organization and Comments

Program Organization and Comments C / C++ PROGRAMMING Program Organization and Comments Copyright 2013 Dan McElroy Programming Organization The layout of a program should be fairly straight forward and simple. Although it may just look

More information

Understanding main() function Input/Output Streams

Understanding main() function Input/Output Streams Understanding main() function Input/Output Streams Structure of a program // my first program in C++ #include int main () { cout

More information

How to approach a computational problem

How to approach a computational problem How to approach a computational problem A lot of people find computer programming difficult, especially when they first get started with it. Sometimes the problems are problems specifically related to

More information

Laboratory 0 Week 0 Advanced Structured Programming An Introduction to Visual Studio and C++

Laboratory 0 Week 0 Advanced Structured Programming An Introduction to Visual Studio and C++ Laboratory 0 Week 0 Advanced Structured Programming An Introduction to Visual Studio and C++ 0.1 Introduction This is a session to familiarize working with the Visual Studio development environment. It

More information

To become familiar with array manipulation, searching, and sorting.

To become familiar with array manipulation, searching, and sorting. ELECTRICAL AND COMPUTER ENGINEERING 06-88-211: COMPUTER AIDED ANALYSIS LABORATORY EXPERIMENT #2: INTRODUCTION TO ARRAYS SID: OBJECTIVE: SECTIONS: Total Mark (out of 20): To become familiar with array manipulation,

More information

Computer Programming. Basic Control Flow - Loops. Adapted from C++ for Everyone and Big C++ by Cay Horstmann, John Wiley & Sons

Computer Programming. Basic Control Flow - Loops. Adapted from C++ for Everyone and Big C++ by Cay Horstmann, John Wiley & Sons Computer Programming Basic Control Flow - Loops Adapted from C++ for Everyone and Big C++ by Cay Horstmann, John Wiley & Sons Objectives To learn about the three types of loops: while for do To avoid infinite

More information

Lab # 02. Basic Elements of C++ _ Part1

Lab # 02. Basic Elements of C++ _ Part1 Lab # 02 Basic Elements of C++ _ Part1 Lab Objectives: After performing this lab, the students should be able to: Become familiar with the basic components of a C++ program, including functions, special

More information

Computer Science II Lecture 1 Introduction and Background

Computer Science II Lecture 1 Introduction and Background Computer Science II Lecture 1 Introduction and Background Discussion of Syllabus Instructor, TAs, office hours Course web site, http://www.cs.rpi.edu/courses/fall04/cs2, will be up soon Course emphasis,

More information

First C or C++ Lab Paycheck-V1.0 Using Microsoft Visual Studio

First C or C++ Lab Paycheck-V1.0 Using Microsoft Visual Studio C & C++ LAB ASSIGNMENT #1 First C or C++ Lab Paycheck-V1.0 Using Microsoft Visual Studio Copyright 2013 Dan McElroy Paycheck-V1.0 The purpose of this lab assignment is to enter a C or C++ into Visual Studio

More information

Superior University. Department of Electrical Engineering CS-115. Computing Fundamentals. Experiment No.1

Superior University. Department of Electrical Engineering CS-115. Computing Fundamentals. Experiment No.1 Superior University Department of Electrical Engineering CS-115 Computing Fundamentals Experiment No.1 Introduction of Compiler, Comments, Program Structure, Input Output, Data Types and Arithmetic Operators

More information

QUICK EXCEL TUTORIAL. The Very Basics

QUICK EXCEL TUTORIAL. The Very Basics QUICK EXCEL TUTORIAL The Very Basics You Are Here. Titles & Column Headers Merging Cells Text Alignment When we work on spread sheets we often need to have a title and/or header clearly visible. Merge

More information

Your First C++ Program. September 1, 2010

Your First C++ Program. September 1, 2010 Your First C++ Program September 1, 2010 Your First C++ Program //*********************************************************** // File name: hello.cpp // Author: Bob Smith // Date: 09/01/2010 // Purpose:

More information

C++ Support Classes (Data and Variables)

C++ Support Classes (Data and Variables) C++ Support Classes (Data and Variables) School of Mathematics 2018 Today s lecture Topics: Computers and Programs; Syntax and Structure of a Program; Data and Variables; Aims: Understand the idea of programming

More information

Maciej Sobieraj. Lecture 1

Maciej Sobieraj. Lecture 1 Maciej Sobieraj Lecture 1 Outline 1. Introduction to computer programming 2. Advanced flow control and data aggregates Your first program First we need to define our expectations for the program. They

More information

Programming in Java Prof. Debasis Samanta Department of Computer Science Engineering Indian Institute of Technology, Kharagpur

Programming in Java Prof. Debasis Samanta Department of Computer Science Engineering Indian Institute of Technology, Kharagpur Programming in Java Prof. Debasis Samanta Department of Computer Science Engineering Indian Institute of Technology, Kharagpur Lecture 04 Demonstration 1 So, we have learned about how to run Java programs

More information

Lab: Supplying Inputs to Programs

Lab: Supplying Inputs to Programs Steven Zeil May 25, 2013 Contents 1 Running the Program 2 2 Supplying Standard Input 4 3 Command Line Parameters 4 1 In this lab, we will look at some of the different ways that basic I/O information can

More information

My First Command-Line Program

My First Command-Line Program 1. Tutorial Overview My First Command-Line Program In this tutorial, you re going to create a very simple command-line application that runs in a window. Unlike a graphical user interface application where

More information

These are notes for the third lecture; if statements and loops.

These are notes for the third lecture; if statements and loops. These are notes for the third lecture; if statements and loops. 1 Yeah, this is going to be the second slide in a lot of lectures. 2 - Dominant language for desktop application development - Most modern

More information

DOWNLOAD PDF MICROSOFT EXCEL ALL FORMULAS LIST WITH EXAMPLES

DOWNLOAD PDF MICROSOFT EXCEL ALL FORMULAS LIST WITH EXAMPLES Chapter 1 : Examples of commonly used formulas - Office Support A collection of useful Excel formulas for sums and counts, dates and times, text manipularion, conditional formatting, percentages, Excel

More information

4. Structure of a C++ program

4. Structure of a C++ program 4.1 Basic Structure 4. Structure of a C++ program The best way to learn a programming language is by writing programs. Typically, the first program beginners write is a program called "Hello World", which

More information

2 nd Week Lecture Notes

2 nd Week Lecture Notes 2 nd Week Lecture Notes Scope of variables All the variables that we intend to use in a program must have been declared with its type specifier in an earlier point in the code, like we did in the previous

More information

Chapter 1 Introduction

Chapter 1 Introduction Chapter 1 Introduction Hi! Welcome to my beginners guide to C++. If you are starting to program for the first time, I hope that you find the chapters I have written useful. C++ is an excellent language

More information

Objectives. Chapter 2: Basic Elements of C++ Introduction. Objectives (cont d.) A C++ Program (cont d.) A C++ Program

Objectives. Chapter 2: Basic Elements of C++ Introduction. Objectives (cont d.) A C++ Program (cont d.) A C++ Program Objectives Chapter 2: Basic Elements of C++ In this chapter, you will: Become familiar with functions, special symbols, and identifiers in C++ Explore simple data types Discover how a program evaluates

More information

Chapter 2: Basic Elements of C++

Chapter 2: Basic Elements of C++ Chapter 2: Basic Elements of C++ Objectives In this chapter, you will: Become familiar with functions, special symbols, and identifiers in C++ Explore simple data types Discover how a program evaluates

More information

Chapter 2: Basic Elements of C++ Objectives. Objectives (cont d.) A C++ Program. Introduction

Chapter 2: Basic Elements of C++ Objectives. Objectives (cont d.) A C++ Program. Introduction Chapter 2: Basic Elements of C++ C++ Programming: From Problem Analysis to Program Design, Fifth Edition 1 Objectives In this chapter, you will: Become familiar with functions, special symbols, and identifiers

More information

Intro to Programming & C Why Program? 1.2 Computer Systems: Hardware and Software. Why Learn to Program?

Intro to Programming & C Why Program? 1.2 Computer Systems: Hardware and Software. Why Learn to Program? Intro to Programming & C++ Unit 1 Sections 1.1-4 and 2.1-10, 2.12-13, 2.15-17 CS 1428 Spring 2019 Jill Seaman 1.1 Why Program? Computer programmable machine designed to follow instructions Program a set

More information

Separate Compilation of Multi-File Programs

Separate Compilation of Multi-File Programs 1 About Compiling What most people mean by the phrase "compiling a program" is actually two separate steps in the creation of that program. The rst step is proper compilation. Compilation is the translation

More information

Linux Tutorial #1. Introduction. Login to a remote Linux machine. Using vim to create and edit C++ programs

Linux Tutorial #1. Introduction. Login to a remote Linux machine. Using vim to create and edit C++ programs Linux Tutorial #1 Introduction The Linux operating system is now over 20 years old, and is widely used in industry and universities because it is fast, flexible and free. Because Linux is open source,

More information

Starting to Program in C++ (Basics & I/O)

Starting to Program in C++ (Basics & I/O) Copyright by Bruce A. Draper. 2017, All Rights Reserved. Starting to Program in C++ (Basics & I/O) On Tuesday of this week, we started learning C++ by example. We gave you both the Complex class code and

More information

Add Subtract Multiply Divide

Add Subtract Multiply Divide ARITHMETIC OPERATORS if AND if/else AND while LOOP Order of Operation (Precedence Part 1) Copyright 2014 Dan McElroy Add Subtract Multiply Divide + Add - Subtract * Multiply / Divide = gives the quotient

More information

Review. Modules. CS 151 Review #6. Sample Program 6.1a:

Review. Modules. CS 151 Review #6. Sample Program 6.1a: Review Modules A key element of structured (well organized and documented) programs is their modularity: the breaking of code into small units. These units, or modules, that do not return a value are called

More information

Review. Relational Operators. The if Statement. CS 151 Review #4

Review. Relational Operators. The if Statement. CS 151 Review #4 Review Relational Operators You have already seen that the statement total=5 is an assignment statement; that is, the integer 5 is placed in the variable called total. Nothing relevant to our everyday

More information

The sequence of steps to be performed in order to solve a problem by the computer is known as an algorithm.

The sequence of steps to be performed in order to solve a problem by the computer is known as an algorithm. CHAPTER 1&2 OBJECTIVES After completing this chapter, you will be able to: Understand the basics and Advantages of an algorithm. Analysis various algorithms. Understand a flowchart. Steps involved in designing

More information

Lesson 14 Final Exam Project Directions CIS105 Survey of Computer Information Systems

Lesson 14 Final Exam Project Directions CIS105 Survey of Computer Information Systems Lesson 14 Final Exam Project Directions CIS105 Survey of Computer Information Systems OVERVIEW For your At-Home Final Exam Part 1: Project, you must complete all four sections using Microsoft Word, PowerPoint,

More information

Programming. C++ Basics

Programming. C++ Basics Programming C++ Basics Introduction to C++ C is a programming language developed in the 1970s with the UNIX operating system C programs are efficient and portable across different hardware platforms C++

More information

Chapter 1 INTRODUCTION

Chapter 1 INTRODUCTION Chapter 1 INTRODUCTION A digital computer system consists of hardware and software: The hardware consists of the physical components of the system. The software is the collection of programs that a computer

More information

EXCEL BASICS: PROJECTS

EXCEL BASICS: PROJECTS EXCEL BASICS: PROJECTS In this class, you will be practicing with three basic Excel worksheets to learn a variety of foundational skills necessary for more advanced projects. This class covers: Three Project

More information

Discussion 1H Notes (Week 3, April 14) TA: Brian Choi Section Webpage:

Discussion 1H Notes (Week 3, April 14) TA: Brian Choi Section Webpage: Discussion 1H Notes (Week 3, April 14) TA: Brian Choi (schoi@cs.ucla.edu) Section Webpage: http://www.cs.ucla.edu/~schoi/cs31 More on Arithmetic Expressions The following two are equivalent:! x = x + 5;

More information

Computer Programming : C++

Computer Programming : C++ The Islamic University of Gaza Engineering Faculty Department of Computer Engineering Fall 2017 ECOM 2003 Muath i.alnabris Computer Programming : C++ Experiment #1 Basics Contents Structure of a program

More information

Variables. Data Types.

Variables. Data Types. Variables. Data Types. The usefulness of the "Hello World" programs shown in the previous section is quite questionable. We had to write several lines of code, compile them, and then execute the resulting

More information

Focus Group Analysis

Focus Group Analysis Focus Group Analysis Contents FOCUS GROUP ANALYSIS... 1 HOW CAN MAXQDA SUPPORT FOCUS GROUP ANALYSIS?... 1 IMPORTING FOCUS GROUP TRANSCRIPTS... 1 TRANFORMING AN ALREADY IMPORTED TEXT INTO A FOCUS GROUP

More information

GE U111 Engineering Problem Solving & Computation Lecture 6 February 2, 2004

GE U111 Engineering Problem Solving & Computation Lecture 6 February 2, 2004 GE U111 Engineering Problem Solving & Computation Lecture 6 February 2, 2004 Functions and Program Structure Today we will be learning about functions. You should already have an idea of their uses. Cout

More information

Learning Worksheet Fundamentals

Learning Worksheet Fundamentals 1.1 LESSON 1 Learning Worksheet Fundamentals After completing this lesson, you will be able to: Create a workbook. Create a workbook from a template. Understand Microsoft Excel window elements. Select

More information

Introduction to Programming using C++

Introduction to Programming using C++ Introduction to Programming using C++ Lecture One: Getting Started Carl Gwilliam gwilliam@hep.ph.liv.ac.uk http://hep.ph.liv.ac.uk/~gwilliam/cppcourse Course Prerequisites What you should already know

More information

Table of Contents. 1. Creating a Microsoft Excel Workbook...1 EVALUATION COPY

Table of Contents. 1. Creating a Microsoft Excel Workbook...1 EVALUATION COPY Table of Contents Table of Contents 1. Creating a Microsoft Excel Workbook...1 Starting Microsoft Excel...1 Creating a Workbook...2 Saving a Workbook...3 The Status Bar...5 Adding and Deleting Worksheets...6

More information

Excel 2016 Basics for Windows

Excel 2016 Basics for Windows Excel 2016 Basics for Windows Excel 2016 Basics for Windows Training Objective To learn the tools and features to get started using Excel 2016 more efficiently and effectively. What you can expect to learn

More information

Chapter 11 Pointers Part 3 (Putting it all together) Student Learning Outcomes (SLOs)

Chapter 11 Pointers Part 3 (Putting it all together) Student Learning Outcomes (SLOs) Chapter 11 Pointers Part 3 (Putting it all together) Student Learning Outcomes (SLOs) a. Create a hierarchy diagram of link list operations. b. Edit a record in a linked list. c. Describe the use of the

More information

Functions that Return a Value. Approximate completion time Pre-lab Reading Assignment 20 min. 92

Functions that Return a Value. Approximate completion time Pre-lab Reading Assignment 20 min. 92 L E S S O N S E T 6.2 Functions that Return a Value PURPOSE PROCEDURE 1. To introduce the concept of scope 2. To understand the difference between static, local and global variables 3. To introduce the

More information

VARIABLES & ASSIGNMENTS

VARIABLES & ASSIGNMENTS Fall 2018 CS150 - Intro to CS I 1 VARIABLES & ASSIGNMENTS Sections 2.1, 2.2, 2.3, 2.4 Fall 2018 CS150 - Intro to CS I 2 Variables Named storage location for holding data named piece of memory You need

More information

C++ Basics. Data Processing Course, I. Hrivnacova, IPN Orsay

C++ Basics. Data Processing Course, I. Hrivnacova, IPN Orsay C++ Basics Data Processing Course, I. Hrivnacova, IPN Orsay The First Program Comments Function main() Input and Output Namespaces Variables Fundamental Types Operators Control constructs 1 C++ Programming

More information

Expressions, Input, Output and Data Type Conversions

Expressions, Input, Output and Data Type Conversions L E S S O N S E T 3 Expressions, Input, Output and Data Type Conversions PURPOSE 1. To learn input and formatted output statements 2. To learn data type conversions (coercion and casting) 3. To work with

More information

Microsoft Excel Level 2

Microsoft Excel Level 2 Microsoft Excel Level 2 Table of Contents Chapter 1 Working with Excel Templates... 5 What is a Template?... 5 I. Opening a Template... 5 II. Using a Template... 5 III. Creating a Template... 6 Chapter

More information

C++ Basics. Lecture 2 COP 3014 Spring January 8, 2018

C++ Basics. Lecture 2 COP 3014 Spring January 8, 2018 C++ Basics Lecture 2 COP 3014 Spring 2018 January 8, 2018 Structure of a C++ Program Sequence of statements, typically grouped into functions. function: a subprogram. a section of a program performing

More information

Lesson 2 Variables and I/O

Lesson 2 Variables and I/O Lesson 2 Variables and I/O Pic 10A Ricardo Salazar Free form layout C++ lets you use spaces and returns (enter key) wherever you see fit. cout

More information

Chapter Four: Loops II

Chapter Four: Loops II Chapter Four: Loops II Slides by Evan Gallagher & Nikolay Kirov Chapter Goals To understand nested loops To implement programs that read and process data sets To use a computer for simulations Processing

More information

CS 241 Computer Programming. Introduction. Teacher Assistant. Hadeel Al-Ateeq

CS 241 Computer Programming. Introduction. Teacher Assistant. Hadeel Al-Ateeq CS 241 Computer Programming Introduction Teacher Assistant Hadeel Al-Ateeq 1 2 Course URL: http://241cs.wordpress.com/ Hadeel Al-Ateeq 3 Textbook HOW TO PROGRAM BY C++ DEITEL AND DEITEL, Seventh edition.

More information

Programming with C++ Language

Programming with C++ Language Programming with C++ Language Fourth stage Prepared by: Eng. Samir Jasim Ahmed Email: engsamirjasim@yahoo.com Prepared By: Eng. Samir Jasim Page 1 Introduction: Programming languages: A programming language

More information

Access: You will have to

Access: You will have to Access: You will have to Create a new blank database Import data from a text file and set up the fields correctly Add some records to the table Create some reports. o For these reports you will need to

More information

LAB: INTRODUCTION TO FUNCTIONS IN C++

LAB: INTRODUCTION TO FUNCTIONS IN C++ LAB: INTRODUCTION TO FUNCTIONS IN C++ MODULE 2 JEFFREY A. STONE and TRICIA K. CLARK COPYRIGHT 2014 VERSION 4.0 PALMS MODULE 2 LAB: FUNCTIONS IN C++ 2 Introduction This lab will provide students with an

More information

University of Technology. Laser & Optoelectronics Engineering Department. C++ Lab.

University of Technology. Laser & Optoelectronics Engineering Department. C++ Lab. University of Technology Laser & Optoelectronics Engineering Department C++ Lab. Fifth week Control Structures A program is usually not limited to a linear sequence of instructions. During its process

More information

CMPE110 - EXPERIMENT 1 * MICROSOFT VISUAL STUDIO AND C++ PROGRAMMING

CMPE110 - EXPERIMENT 1 * MICROSOFT VISUAL STUDIO AND C++ PROGRAMMING CMPE110 - EXPERIMENT 1 * MICROSOFT VISUAL STUDIO AND C++ PROGRAMMING Aims 1. Learning primary functions of Microsoft Visual Studio 2008 * 2. Introduction to C++ Programming 3. Running C++ programs using

More information

INFORMATION SHEET 24002/1: AN EXCEL PRIMER

INFORMATION SHEET 24002/1: AN EXCEL PRIMER INFORMATION SHEET 24002/1: AN EXCEL PRIMER How to use this document This guide to the basics of Microsoft Excel is intended for those people who use the program, but need or wish to know more than the

More information

Why Is Repetition Needed?

Why Is Repetition Needed? Why Is Repetition Needed? Repetition allows efficient use of variables. It lets you process many values using a small number of variables. For example, to add five numbers: Inefficient way: Declare a variable

More information

Chapter 2 C++ Fundamentals

Chapter 2 C++ Fundamentals Chapter 2 C++ Fundamentals 3rd Edition Computing Fundamentals with C++ Rick Mercer Franklin, Beedle & Associates Goals Reuse existing code in your programs with #include Obtain input data from the user

More information

Computer Science is...

Computer Science is... Computer Science is... Automated Software Verification Using mathematical logic, computer scientists try to design tools to automatically detect runtime and logical errors in huge, complex programs. Right:

More information

conditional statements

conditional statements L E S S O N S E T 4 Conditional Statements PU RPOSE PROCE DU RE 1. To work with relational operators 2. To work with conditional statements 3. To learn and use nested if statements 4. To learn and use

More information

CSE 142 Su 04 Computer Programming 1 - Java. Objects

CSE 142 Su 04 Computer Programming 1 - Java. Objects Objects Objects have state and behavior. State is maintained in instance variables which live as long as the object does. Behavior is implemented in methods, which can be called by other objects to request

More information

Object-Oriented Programming, Iouliia Skliarova

Object-Oriented Programming, Iouliia Skliarova Object-Oriented Programming, Iouliia Skliarova CBook a = CBook("C++", 2014); CBook b = CBook("Physics", 1960); a.display(); b.display(); void CBook::Display() cout

More information

download instant at Introduction to C++

download instant at  Introduction to C++ Introduction to C++ 2 Programming, Input/Output and Operators What s in a name? that which we call a rose By any other name would smell as sweet. William Shakespeare High thoughts must have high language.

More information

Microsoft Access XP (2002) - Advanced Queries

Microsoft Access XP (2002) - Advanced Queries Microsoft Access XP (2002) - Advanced Queries Group/Summary Operations Change Join Properties Not Equal Query Parameter Queries Working with Text IIF Queries Expression Builder Backing up Tables Action

More information

Chapter Four: Loops. Slides by Evan Gallagher. C++ for Everyone by Cay Horstmann Copyright 2012 by John Wiley & Sons. All rights reserved

Chapter Four: Loops. Slides by Evan Gallagher. C++ for Everyone by Cay Horstmann Copyright 2012 by John Wiley & Sons. All rights reserved Chapter Four: Loops Slides by Evan Gallagher The Three Loops in C++ C++ has these three looping statements: while for do The while Loop while (condition) { statements } The condition is some kind of test

More information

Computer Programming

Computer Programming Computer Programming Dr. Deepak B Phatak Dr. Supratik Chakraborty Department of Computer Science and Engineering Session: Structure of a Simple C++ Program Dr. Deepak B. Phatak & Dr. Supratik Chakraborty,

More information

Cpt S 122 Data Structures. Introduction to C++ Part II

Cpt S 122 Data Structures. Introduction to C++ Part II Cpt S 122 Data Structures Introduction to C++ Part II Nirmalya Roy School of Electrical Engineering and Computer Science Washington State University Topics Objectives Defining class with a member function

More information

Overview. - General Data Types - Categories of Words. - Define Before Use. - The Three S s. - End of Statement - My First Program

Overview. - General Data Types - Categories of Words. - Define Before Use. - The Three S s. - End of Statement - My First Program Overview - General Data Types - Categories of Words - The Three S s - Define Before Use - End of Statement - My First Program a description of data, defining a set of valid values and operations List of

More information

Discussion 1H Notes (Week 2, 4/8) TA: Brian Choi Section Webpage:

Discussion 1H Notes (Week 2, 4/8) TA: Brian Choi Section Webpage: Discussion 1H Notes (Week 2, 4/8) TA: Brian Choi (schoi@cs.ucla.edu) Section Webpage: http://www.cs.ucla.edu/~schoi/cs31 Variables You have to instruct your computer every little thing it needs to do even

More information

Lab 1: First Steps in C++ - Eclipse

Lab 1: First Steps in C++ - Eclipse Lab 1: First Steps in C++ - Eclipse Step Zero: Select workspace 1. Upon launching eclipse, we are ask to chose a workspace: 2. We select a new workspace directory (e.g., C:\Courses ): 3. We accept the

More information

T H E I N T E R A C T I V E S H E L L

T H E I N T E R A C T I V E S H E L L 3 T H E I N T E R A C T I V E S H E L L The Analytical Engine has no pretensions whatever to originate anything. It can do whatever we know how to order it to perform. Ada Lovelace, October 1842 Before

More information

The American University in Cairo Department of Computer Science & Engineering CSCI &09 Dr. KHALIL Exam-I Fall 2011

The American University in Cairo Department of Computer Science & Engineering CSCI &09 Dr. KHALIL Exam-I Fall 2011 The American University in Cairo Department of Computer Science & Engineering CSCI 106-07&09 Dr. KHALIL Exam-I Fall 2011 Last Name :... ID:... First Name:... Form I Section No.: EXAMINATION INSTRUCTIONS

More information

Chapter 1 Introduction to Computers and C++ Programming

Chapter 1 Introduction to Computers and C++ Programming Chapter 1 Introduction to Computers and C++ Programming 1 Outline 1.1 Introduction 1.2 What is a Computer? 1.3 Computer Organization 1.7 History of C and C++ 1.14 Basics of a Typical C++ Environment 1.20

More information

Tutorial 13 Salary Survey Application: Introducing One- Dimensional Arrays

Tutorial 13 Salary Survey Application: Introducing One- Dimensional Arrays Tutorial 13 Salary Survey Application: Introducing One- Dimensional Arrays Outline 13.1 Test-Driving the Salary Survey Application 13.2 Introducing Arrays 13.3 Declaring and Initializing Arrays 13.4 Constructing

More information

CS/IT 114 Introduction to Java, Part 1 FALL 2016 CLASS 2: SEP. 8TH INSTRUCTOR: JIAYIN WANG

CS/IT 114 Introduction to Java, Part 1 FALL 2016 CLASS 2: SEP. 8TH INSTRUCTOR: JIAYIN WANG CS/IT 114 Introduction to Java, Part 1 FALL 2016 CLASS 2: SEP. 8TH INSTRUCTOR: JIAYIN WANG 1 Notice Class Website http://www.cs.umb.edu/~jane/cs114/ Reading Assignment Chapter 1: Introduction to Java Programming

More information

1- Write a single C++ statement that: A. Calculates the sum of the two integrates 11 and 12 and outputs the sum to the consol.

1- Write a single C++ statement that: A. Calculates the sum of the two integrates 11 and 12 and outputs the sum to the consol. 1- Write a single C++ statement that: A. Calculates the sum of the two integrates 11 and 12 and outputs the sum to the consol. B. Outputs to the console a floating point number f1 in scientific format

More information

7/8/10 KEY CONCEPTS. Problem COMP 10 EXPLORING COMPUTER SCIENCE. Algorithm. Lecture 2 Variables, Types, and Programs. Program PROBLEM SOLVING

7/8/10 KEY CONCEPTS. Problem COMP 10 EXPLORING COMPUTER SCIENCE. Algorithm. Lecture 2 Variables, Types, and Programs. Program PROBLEM SOLVING KEY CONCEPTS COMP 10 EXPLORING COMPUTER SCIENCE Lecture 2 Variables, Types, and Programs Problem Definition of task to be performed (by a computer) Algorithm A particular sequence of steps that will solve

More information

Introduction to C++ Programming Pearson Education, Inc. All rights reserved.

Introduction to C++ Programming Pearson Education, Inc. All rights reserved. 1 2 Introduction to C++ Programming 2 What s in a name? that which we call a rose By any other name would smell as sweet. William Shakespeare When faced with a decision, I always ask, What would be the

More information

Scientific Computing

Scientific Computing Scientific Computing Martin Lotz School of Mathematics The University of Manchester Lecture 1, September 22, 2014 Outline Course Overview Programming Basics The C++ Programming Language Outline Course

More information

CE221 Programming in C++ Part 1 Introduction

CE221 Programming in C++ Part 1 Introduction CE221 Programming in C++ Part 1 Introduction 06/10/2017 CE221 Part 1 1 Module Schedule There are two lectures (Monday 13.00-13.50 and Tuesday 11.00-11.50) each week in the autumn term, and a 2-hour lab

More information

Programming in C++ Prof. Partha Pratim Das Department of Computer Science and Engineering Indian Institute of Technology, Kharagpur

Programming in C++ Prof. Partha Pratim Das Department of Computer Science and Engineering Indian Institute of Technology, Kharagpur Programming in C++ Prof. Partha Pratim Das Department of Computer Science and Engineering Indian Institute of Technology, Kharagpur Lecture 04 Programs with IO and Loop We will now discuss the module 2,

More information

COSC 2P95. Procedural Abstraction. Week 3. Brock University. Brock University (Week 3) Procedural Abstraction 1 / 26

COSC 2P95. Procedural Abstraction. Week 3. Brock University. Brock University (Week 3) Procedural Abstraction 1 / 26 COSC 2P95 Procedural Abstraction Week 3 Brock University Brock University (Week 3) Procedural Abstraction 1 / 26 Procedural Abstraction We ve already discussed how to arrange complex sets of actions (e.g.

More information

The American University in Cairo Computer Science & Engineering Department CSCE Dr. KHALIL Exam II Spring 2010

The American University in Cairo Computer Science & Engineering Department CSCE Dr. KHALIL Exam II Spring 2010 The American University in Cairo Computer Science & Engineering Department CSCE 106-08 Dr. KHALIL Exam II Spring 2010 Last Name :... ID:... First Name:... Form - I EXAMINATION INSTRUCTIONS * Do not turn

More information

Programming. Computer. Program. Programming Language. Execute sequence of simple (primitive) instructions What instructions should be provided?

Programming. Computer. Program. Programming Language. Execute sequence of simple (primitive) instructions What instructions should be provided? C++ Basics Programming Computer Execute sequence of simple (primitive) instructions What instructions should be provided? Is there a minimum set? (See Turing Machine) Generic Reduce future limitations

More information

Civil Engineering Computation

Civil Engineering Computation Civil Engineering Computation First Steps in VBA Homework Evaluation 2 1 Homework Evaluation 3 Based on this rubric, you may resubmit Homework 1 and Homework 2 (along with today s homework) by next Monday

More information

CS 216 Fall 2007 Midterm 1 Page 1 of 10 Name: ID:

CS 216 Fall 2007 Midterm 1 Page 1 of 10 Name:  ID: Page 1 of 10 Name: Email ID: You MUST write your name and e-mail ID on EACH page and bubble in your userid at the bottom of EACH page including this page and page 10. If you do not do this, you will receive

More information

Lab 4: Introduction to Programming

Lab 4: Introduction to Programming _ Unit 2: Programming in C++, pages 1 of 9 Department of Computer and Mathematical Sciences CS 1410 Intro to Computer Science with C++ 4 Lab 4: Introduction to Programming Objectives: The main objective

More information

PIC 10A Objects/Classes

PIC 10A Objects/Classes PIC 10A Objects/Classes Ernest Ryu UCLA Mathematics Last edited: November 13, 2017 User-defined types In C++, we can define our own custom types. Object is synonymous to variable, and class is synonymous

More information

Fundamentals. Fundamentals. Fundamentals. We build up instructions from three types of materials

Fundamentals. Fundamentals. Fundamentals. We build up instructions from three types of materials Fundamentals We build up instructions from three types of materials Constants Expressions Fundamentals Constants are just that, they are values that don t change as our macros are executing Fundamentals

More information

6 Functions. 6.1 Focus on Software Engineering: Modular Programming TOPICS. CONCEPT: A program may be broken up into manageable functions.

6 Functions. 6.1 Focus on Software Engineering: Modular Programming TOPICS. CONCEPT: A program may be broken up into manageable functions. 6 Functions TOPICS 6.1 Focus on Software Engineering: Modular Programming 6.2 Defining and Calling Functions 6.3 Function Prototypes 6.4 Sending Data into a Function 6.5 Passing Data by Value 6.6 Focus

More information

Chapter 1 Introduction to Computers and Programming

Chapter 1 Introduction to Computers and Programming Standard Version of Starting Out with C++, 4th Edition Chapter 1 Introduction to Computers and Programming Copyright 2003 Scott/Jones Publishing Contents 1.1 Why Program? 1.2 Computer Systems: Hardware

More information

VISUAL GUIDE to. RX Scripting. for Roulette Xtreme - System Designer 2.0. L J Howell UX Software Ver. 1.0

VISUAL GUIDE to. RX Scripting. for Roulette Xtreme - System Designer 2.0. L J Howell UX Software Ver. 1.0 VISUAL GUIDE to RX Scripting for Roulette Xtreme - System Designer 2.0 L J Howell UX Software 2009 Ver. 1.0 TABLE OF CONTENTS INTRODUCTION...ii What is this book about?... iii How to use this book... iii

More information

Chapter Overview. C++ Basics. Variables and Assignments. Variables and Assignments. Keywords. Identifiers. 2.1 Variables and Assignments

Chapter Overview. C++ Basics. Variables and Assignments. Variables and Assignments. Keywords. Identifiers. 2.1 Variables and Assignments Chapter 2 C++ Basics Overview 2.1 Variables and Assignments 2.2 Input and Output 2.3 Data Types and Expressions 2.4 Simple Flow of Control 2.5 Program Style Copyright 2011 Pearson Addison-Wesley. All rights

More information