1 / 113

CISC 1600/1610 Computer Science I

CISC 1600/1610 Computer Science I. Programming in C++ Professor Julie Harazduk jharazduk@fordham.edu Office: JMH 338. Each class – Take Attendance on BB. Click the Class Click Tools Click Qwikly Attendance Enter the 4 digit number. This is a course…. In Programming For beginners

saoirse
Download Presentation

CISC 1600/1610 Computer Science I

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. CISC 1600/1610Computer Science I Programming in C++ Professor Julie Harazduk jharazduk@fordham.edu Office: JMH 338

  2. Each class – Take Attendance on BB • Click the Class • Click Tools • Click Qwikly Attendance • Enter the 4 digit number

  3. This is a course… • In Programming • For beginners • who want to become professionals • i.e., people who can produce systems that others will use • who are assumed to be bright • Though not (necessarily) geniuses • who are willing to work hard • Though do need sleep occasionally, and take a normal course load • Using the C++ programming language

  4. Instructor Prof. Julie Harazduk Email: jharazduk@fordham.edu Office hours: Mon-Thu 1:00-2:15 or email me for an appointment Office: JMH 338 Website: http://storm.cis.fordham.edu/harazduk/cs1600

  5. Introduction to programming with C++ Learn • Fundamental programming concepts • Key techniques • Basic C++ facilities By the end of the course, you will be able to: • Write small C++ programs • Read much larger programs • Learn the basics of many other languages • Proceed to advanced C++ courses

  6. Requirements • Attendance and participation • Lectures and lab sessions • Lab assignments – roughly 6-8 across semester • Quizzes – each 15 minutes, 5 across semester • Final project • Exams – 1 midterm, 1 final • Academic integrity – may discuss assignments with your classmates, but you MUST write all your code and all your answers yourself

  7. How to succeed in class Ask questions • In class • In office hours JMH 338, tutor room JMH 301 • Study together and discuss assignments with each other (without plagiarizing!) Read Textbook • Read and re-read the material, self-test! • Complete practice problems Start coding and studying early – PLAY Around!

  8. Course textbook Starting out withC++ from Control Structures through Objects Ninth Edition Tony Gaddis

  9. Course outline • Programming basics, input/output, arithmetic • Conditional statements • Loops • Modularity – functions • Complex data – arrays, strings, and classes Throughout the semester: • Proper programming style

  10. Course Material http://storm.cis.fordham.edu/harazduk/cs1600 Go online for • Announcements • Lecture slides • Course materials/handouts • Assignments

  11. “Two courses in one”: CISC 1600 and CISC 1610 CISC 1600 and 1610 cover lecture and lab • We may work in lab during lecture time • We may have lecture during lab time Listen for announcements during class/online!

  12. A program provides a computer with a set of simple instructions to achieve a goal

  13. Think about a program to put on a jacket? What does it need to do? How exact does it need to be? We’ll come back to it.

  14. Programs are everywhere On your computer: • Web browser • Request and display information from distant sites • Word processor • Record text, change appearance, save to disk • Anywhere else?

  15. Programs are everywhere In the dining hall: • Cashier • Compute price of food purchase, charge payment to account, (if pay cash: compute change) • HVAC • Monitor temperature, adjust A/C or heating And beyond… • Self-Driving Car!

  16. Programs have to be precise • Programs are written in a programming language. • Programs must use correct grammar (syntax). • Programs must have correct logic (semantics). • Programs run on a computer. • Most computers are dumb. • They do exactly what you say to do, not what you meant for them to do. • They can’t fill in missing details. If you leave out a detail, it won’t get done.

  17. Computer system structure Output Central processing unit (CPU) – performs all the instructions Memory – stores data and instructions for CPU Input – collects information from the world Output – provides information to the world CPU Memory Input

  18. Ready to program putting on a jacket? What does it need to do? How exact does it need to be? We’ll come back to it.

  19. Pseudocode to put on a jacket • Pick up jacket with two hands • Repeat the following until the jacket is upright • Turn jacket in x,y dimension 90 degrees • Are sleeve openings facing you? • Turn jacket in x,z dimension 180 degrees • Pick one hand to hold jacket • Place other hand into opposing sleeve and push arm thru…

  20. How do we 'talk to a computer'? • Programming 'Languages' • Like spoken languages: • you must practice • there are several ways to say the same thing • Unlike spoken languages: • The 'answers' are deterministic (predictable) • The grammar is super picky, such as… • Where you put punctuation, capitalization

  21. C++ – high-level language • High-level language • Uses words to describe instructions • More intuitive to people • Computer-independent • Machine-language • Uses binary to describe instructions • Less intuitive to people • Computer-dependent C++ code balance=balance-charge; Compiler assembly code 10000000 10000100 00110010 01110100 machine code

  22. Compiler C++ code balance=balance-charge; Converts your code to Machine code (Sometimes first to Assembly or byte-code, sometimes directly to machine code) Assembly code Machine code 0000 0010 0010 1011 1000 1000 0010 0010

  23. Binary Machine code (binary) is made only of 0s and 1s? Why? 1 Binary Digit is a Bit 8 Binary Digits is a Byte 0000 0010 0010 1011 1000 1000 0010 0010

  24. A Little Bit about Binary • How high can you count on one hand? Finger up is 1 Finger down is 0 Add the values showing Answer= 31 Why? 11111 4 2 8 16 1 This Photo by Unknown Author is licensed under CC BY-SA

  25. Tiny Bit of C++ History • Built as an extension of ‘C’ • C (Kernigan & Ritchie – Bell Labs 1969-1972) • By Bjarne Stroustrup at Bell Labs • (Danish Masters in Math & CS) • Began in 1979. First published in 1985

  26. Why C++? • Popular modern programming language • In use since 1980’s • Similar structure to many/most other popular languages (Java, C#, Perl, Python) • Exposes low level concepts in a high level language. • Take CISC2000/2010 to see the low level and high level constructs.

  27. 1.2 Computer Systems: Hardware and Software

  28. Main Hardware Component Categories: • Central Processing Unit (CPU) • Main Memory • Secondary Memory / Storage • Input Devices • Output Devices

  29. Central Processing Unit (CPU) Comprised of: Control Unit Retrieves and decodes program instructions Coordinates activities of all other parts of computer Arithmetic & Logic Unit Hardware optimized for high-speed numeric calculation Hardware designed for true/false, yes/no decisions

  30. CPU Organization Figure 1-3

  31. Main Memory • Is volatile, meaning not permanent • Values in main memory are lost when a program terminates or computer is turned off. • Can be access in any order • Also called Random Access Memory (RAM) • Is organized as follows: • bit: smallest piece of memory. Has values 0 (off, false) or 1 (on, true) • byte: 8 consecutive bits. Bytes have addresses.

  32. Main Memory • Addresses – Each byte in memory is identified by a unique number known as an address. • In Figure 1-4, the number 149 is stored in the byte with the address 16, and the number 72 is stored at address 23.

  33. Main Memory • Main Memory holds both our programs and our data. • Programs are both data and instructions. • The CPU reads instructions, interprets them and executes them from main memory. • Main Memory is assigned by the system to our program. • We don’t get to pick the address assigned, but we do get to access it.

  34. Secondary Storage • Non-volatile, meaning permanent • data retained when program is not running or computer is turned off • Comes in a variety of media: • magnetic: traditional hard drives that use a moveable mechanical arm to read/write • solid-state: data stored in chips, no moving parts • optical: CD-ROM, DVD • Flash drives, connected to the USB port

  35. Input Devices • Devices that send information to the computer from outside • Many devices can provide input: • Keyboard, mouse, touchscreen, scanner, digital camera, microphone • Disk drives, CD drives, and DVD drives

  36. Software-Programs That Run on a Computer • Categories of software: • System software: programs that manage the computer hardware and the programs that run on them. • Examples: operating systems, utility programs, software development tools • Application software: programs that provide services to the user. • Examples : word processing, games, programs to solve specific problems

  37. 1.1 Why Program?

  38. Why Program? Computer – programmable machine designed to follow instructions Program – instructions in computer memory to make it do something Programmer – person who writes instructions (programs) to make computer perform a task SO, without programmers, no programs; without programs, a computer cannot do anything

  39. 1.3 Programs and Programming Languages

  40. Programs and Programming Languages • We start with a problem that we want to solve. • We need a program that will solve it over and over. • A program is a set of instructions that the computer follows to perform a task • Let’s think about how to calculate gross pay for an hourly worker. • What inputs do we need to calculate gross pay? • We need an algorithm, which is a set of well-defined steps.

  41. Example Algorithm for Calculating Gross Pay

  42. 1.4 What is a Program Made of?

  43. What is a Program Made of? • Common elements in programming languages: • Key Words • Programmer-Defined Identifiers • Operators • Punctuation • Syntax

  44. Program 1-1

  45. Key Words • Also known as reserved words • Have a special meaning in C++ • Can not be used for any other purpose • Key words in the Program 1-1: using, namespace, int, double, and return

  46. Key Words

  47. Machine Language • Although the previous algorithm defines the steps for calculating the gross pay, it is not ready to be executed on the computer. • The computer only executes machinelanguage instructions

  48. Machine Language • Machine language instructions are binary numbers, such as1011010000000101 • Rather than writing programs in machine language, programmers use programming languages.

  49. Programs and Programming Languages • Types of languages: • Low-level: used for communication with computer hardware directly. Often written in binary machine code (0’s/1’s) directly. • High-level: closer to human language

  50. Some Well-Known Programming Languages (Table 1-1 on Page 10) C++ BASIC Ruby Java FORTRAN Visual Basic C# COBOL JavaScript C Python

More Related