Algorithms, problem solving and Introduction to C++

Slides:



Advertisements
Similar presentations
C++ Introduction.
Advertisements

Overview of Programming and Problem Solving ROBERT REAVES.
Software. What Is Software? software –Also called Computer programs –Are a list of instructions –Instructions are called code –CPU performs the instructions.
The father of computing history: Charles Babbage by Anja Jentzsch
INTRODUCTION T.Najah Al_Subaie Kingdom of Saudi Arabia Prince Norah bint Abdul Rahman University College of Computer Since and Information System CS240.
Copyright © 2008 Pearson Addison-Wesley. All rights reserved. Chapter 1 Introduction to Computers and C++ Programming.
Chapter 1 Introduction to Computers and C++ Programming.
C++ Programming: From Problem Analysis to Program Design, Third Edition Chapter 1: An Overview of Computers and Programming Languages C++ Programming:
Chapter 8: Introduction to High-level Language Programming Invitation to Computer Science, C++ Version, Third Edition.
Some of these slides are based on material from the ACM Computing Curricula 2005.
Introduction To C++ Programming 1.0 Basic C++ Program Structure 2.0 Program Control 3.0 Array And Structures 4.0 Function 5.0 Pointer 6.0 Secure Programming.
Programming is instructing a computer to perform a task for you with the help of a programming language.
Copyright 2003 Scott/Jones Publishing Brief Version of Starting Out with C++, 4th Edition Chapter 1 Introduction to Computers and Programming.
1 Chapter 1 Overview of Programming and Problem Solving Dale/Weems Slides based on work by Sylvia Sorkin, Community College of Baltimore County - Essex.
Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 1 Introduction to Computers and C++ Programming.
Instructor: Tina Tian. About me Office: RLC 203A Office Hours: Wednesday 1:30 - 4:30 PM or .
Intro to Programming and JavaScript. What is Programming? Programming is the activity of creating a set of detailed instructions (Program) that when carried.
Copyright © 2008 Pearson Addison-Wesley. All rights reserved. Chapter 1 Introduction to Computers and C++ Programming.
Copyright © 2015 Pearson Education, Ltd.. All rights reserved. Chapter 1 Introduction to Computers and C++ Programming.
Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 1 Introduction to Computers and C++ Programming.
CS 114 – Class 02 Topics  Computer programs  Using the compiler Assignments  Read pages for Thursday.  We will go to the lab on Thursday.
1 Overview of Programming and Problem Solving Chapter 1.
Copyright © 2008 Pearson Addison-Wesley. All rights reserved. Chapter 1 Introduction to Computers and C++ Programming.
Copyright © 2015 Pearson Education, Ltd.. All rights reserved. Chapter 1 Introduction to Computers and C++ Programming.
Mohamed Iqbal Pallipurath Slide 1. Mohamed Iqbal Pallipurath Slide 2 Basics Introduction to Computers and C++ Programming.
Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Slide 1- 1 October 20, October 20, 2015October 20, 2015October 20,
Overview of Programming and Problem Solving Textbook Chapter 1 1.
Basic History of Computing. Al-Khwarizmi written in 830, Hisab al-jabr w’al- muqabalathe al- jabr; in the title we get algebra developed the concept.
National Diploma Unit 4 Introduction to Software Development Introduction to Programming Languages.
N from what language did C++ originate? n what’s input, output device? n what’s main memory, memory location, memory address? n what’s a program, data?
N from what language did C++ originate? n what’s input, output device? n what’s main memory, memory location, memory address? n what’s a program, data?
Copyright © 2012 Pearson Addison-Wesley. All rights reserved. Chapter 1 Introduction to Computers and C++ Programming.
CS Computer Science I. BCPL was developed in 1967 as a language for writing operating systems and software compilers In 1970, the creators of the.
Chapter 1 Computers, Compilers, & Unix. Overview u Computer hardware u Unix u Computer Languages u Compilers.
12/18/2015 CSI Chapter 1 1 Compiler + Linker = Ready to run code Compiler translates high-level language source code into an intermediate object.
Copyright © 2008 Pearson Addison-Wesley. All rights reserved. Chapter 1 Introduction to Computers and C++ Programming.
Introduction to C++.  Computers: CPU, Memory & Input / Output (IO)  Program: Sequence of instructions for the computer.  Operating system: Program.
Chapter 11  Getting ready to program  Hardware Model  Software Model  Programming Languages  Facts about C++  Program Development Process  The Hello-world.
Copyright © 2014 Pearson Addison-Wesley. All rights reserved. Chapter 2 C++ Basics.
Software. Introduction n A computer can’t do anything without a program of instructions. n A program is a set of instructions a computer carries out.
Introduction to Problem Solving Programming is a problem solving activity. When you write a program, you are actually writing an instruction for the computer.
Software Engineering Algorithms, Compilers, & Lifecycle.
CMPT 201 Computer Science II for Engineers
Foundations of Computer Science C & C++ programming lecture 2
ICS 3UI - Introduction to Computer Science
CSCI 161: Introduction to Programming
Introduction to Computers and C++ Programming
Introduction to Computers and C++ Programming
Algorithms, problem solving and Introduction to C++
Introduction to Computers and C++ Programming
Computer Terms Review from what language did C++ originate?
ANNOUNCEMENT The missed lecture will be made up this Monday evening in the Tech PC classroom (MG51). A tentative time interval is 6:30-8:00. The exact.
Computer Programming (BCT 1113)
Introduction to Visual Basic 2008 Programming
Chapter 1: An Overview of Computers and Programming Languages
Beginning C++ Programming
About the Presentations
Chapter 1: An Overview of Computers and Programming Languages
C++ Programming: From Problem Analysis to Program Design
TRANSLATORS AND IDEs Key Revision Points.
Chapter 1: Introduction to Computers and Programming
Chapter 8: Introduction to High-Level Language Programming
Engineering 1020 Introduction to Programming
Chapter 1 Introduction(1.1)
Programming Fundamentals Lecture #3 Overview of Computer Programming
Algorithm and Ambiguity
CS IA: Procedural Programming CS IB: Object-Oriented Programming
Introduction to Computer Programming
Chapter 2 – part a Brent M. Dingle Texas A&M University
Computer Terms Review from what language did C++ originate?
Presentation transcript:

Algorithms, problem solving and Introduction to C++ Day 2 Algorithms, problem solving and Introduction to C++

Algorithms Algorithm A sequence of precise instructions which leads to a solution (historically, the term had a more specialized meaning) Program An algorithm expressed in a language the computer can understand

Consider A long list of names… Bill Sally Robert Catherine Lora Jennifer ….. How can we determine ho many instances there are of the name “Lora”?

Algorithm

An Algorithm is precise To qualify as an algorithm, a set of instructions must completely and unambiguously specify the steps to be taken and the order in which they are taken. The person or machine carrying out the algorithm does exactly what the algorithm says, neither more nor less.

Computing history The Antikythera mechanism, invented some time around 100 BC in ancient Greece, is the first known mechanical calculator utilizing gears of various sizes and configuration to perform calculations. Tracked the metonic cycle still used in lunar-to-solar calendars, and which is consistent for calculating the dates of the Olympiads.

History The Kurdish medieval scientist Al-Jazari built programmable automata in 1206 AD. One system employed in these devices was the use of pegs and cams placed into a wooden drum at specific locations, which would sequentially trigger levers that in turn operated percussion instruments. The output of this device was a small drummer playing various rhythms and drum patterns.

History The Jacquard loom, which Joseph Marie Jacquard developed in 1801, uses a series of pasteboard cards with holes punched in them. The hole pattern represented the pattern that the loom had to follow in weaving cloth. Repeatable automated proceedures.

History Charles Babbage adopted the use of punched cards around 1830 to control his Analytical Engine. This was an engine for calculating mathematical and astronomical tables

History Some believe that the first computer program was written for the Analytical Engine by mathematician Ada Lovelace to calculate a sequence of Bernoulli numbers.

History – The difference engine Charles Babbage also designed the first computer that actually stored a program in memory (rather then a fixed program on cards). He was unable to complete the complex machine, but was built later, and it worked perfectly!

History – Difference Engine The difference engine was built recently with Legos! video video

Program Design Programming is a creative process No complete set of rules for creating a program Problem Solving Phase Algorithm Implementation Phase Program Slide 1- 13

Problem Solving Phase Be certain the task is completely specified What is the input? What information is in the output? How is the output organized? Develop the algorithm before implementation Experience shows this saves time in getting your program to run. Test the algorithm for correctness Slide 1- 14

Implementation Phase Translate the algorithm into a programming language Easier as you gain experience with the language Compile the source code Locates errors in using the programming language Run the program on sample data Verify correctness of results Results may require modification of the algorithm and program Slide 1- 15

Display 1.7 Slide 1- 16

Object Oriented Programming An Object Abbreviated OOP Memory or State The program for the object Slide 1- 17

Object Oriented Programming Objects represent “entities” we are modeling. An entity is a actor in a process

Creative Software Life Cycle Evaluate Goals Review For Planning System Algorithms Creative Programs Slide 1- 19

Introduction to C++

Hands on 1 – NetBeans 8.1 IDE Open Netbeans (in application folder) Select File/New Project Pick "C/C++ " on left, "C/C++" Application on right, hit next Give name "helloworld" Select a project location (your H drive is best), hit finish Open source folder, main.cpp Paste the following code into main.cpp, replacing the existing code. (See CodeDay2 on Wiki)

#include <iostream> using namespace std; int main() { cout << "Hello, world." << endl; } Helloworld.cpp

Hands on – ideone (web based) Go to ideone.com This is a web page that allows quick testing of simple programs At the bottom left corner set to C++ 14 Paste in the hello world code from sample code into main code area. Hit run button What happens?

Introduction to C++ Where did C++ come from? Derived from the C language C was derived from the B language B was derived from the BCPL language Why the ‘++’? ++ is an operator in C++ and results in a cute pun Slide 1- 24

C++ History Bell Labs in the 1970s. Used to maintain UNIX systems Many commercial applications written in C Bell Labs in the 1980s. Overcame several shortcomings of C Incorporated object oriented programming C remains a subset of C++ Slide 1- 25

A Sample C++ Program #include <iostream> using namespace std; int main() { cout << "Hello, world." << endl; return 0; } Associates I/O libraries “main” program function Return control to operating system Program code Braces surround ALL blocks of code . Slide 1- 26

Display 1.9 Slide 1- 27

In class Make program give personnal greeting e.g. “Hello Olivia” Make program print your address on multiple lines. Make the system print out your first name as a text banner: # # ###### # # # # #### # # # # # ## # # # # # ## # #### ##### # # # # # # # # # # # # # # # # # # # # # # # # # ## # # # # ## # # ###### # # # #### # #