week 1 - Introduction Goals

Slides:



Advertisements
Similar presentations
Chapter 7: User-Defined Functions II
Advertisements

George Blank University Lecturer. CS 602 Java and the Web Object Oriented Software Development Using Java Chapter 4.
COSC 120 Computer Programming
Chapter 10.
1 Lecture 6 Chapter 3 Numeric Types, Expressions, and Output Dale/Weems/Headington.
Operator Overloading in C++ Systems Programming. Systems Programming: Operator Overloading 22   Fundamentals of Operator Overloading   Restrictions.
Your First C++ Program Aug 27, /27/08 CS 150 Introduction to Computer Science I C++  Based on the C programming language  One of today’s most.
1 September 6, 2005CS150 Introduction to Computer Science I What Actions Do We Have Part 1 CS150 Introduction to Computer Science I.
How to Program in C++ CHAPTER 3: INPUT & OUTPUT INSTRUCTOR: MOHAMMAD MOJADDAM.
Streams, Files. 2 Stream Stream is a sequence of bytes Input stream In input operations, the bytes are transferred from a device to the main memory Output.
Copyright 2003 Scott/Jones Publishing Brief Version of Starting Out with C++, 4th Edition Chapter 1 Introduction to Computers and Programming.
Copyright © 2012 Pearson Education, Inc. Chapter 1: Introduction to Computers and Programming.
Stream Handling Streams - means flow of data to and from program variables. - We declare the variables in our C++ for holding data temporarily in the memory.
High-Level Programming Languages: C++
Comp 245 Data Structures Linked Lists. An Array Based List Usually is statically allocated; may not use memory efficiently Direct access to data; faster.
File I/O ifstreams and ofstreams Sections 11.1 &
C++ History C++ was designed at AT&T Bell Labs by Bjarne Stroustrup in the early 80's Based on the ‘C’ programming language C++ language standardised in.
1 CS161 Introduction to Computer Science Topic #13.
Chapter 0 Getting Started. Objectives Understand the basic structure of a C++ program including: – Comments – Preprocessor instructions – Main function.
CPSC 252 Operator Overloading and Convert Constructors Page 1 Operator overloading We would like to assign an element to a vector or retrieve an element.
File I/O 1 ifstreams and ofstreams Sections 11.1 & 11.2.
CSE 332: C++ IO We’ve Looked at Basic Input and Output Already How to move data into and out of a program –Using argc and argv to pass command line args.
1 Character Strings (Cstrings) Reference: CS215 textbook pages
1 Today’s Objectives  Announcements Homework #3 is due on Monday, 10-Jul, however you can earn 10 bonus points for this HW if you turn it in on Wednesday,
Chapter 3 Functions. 2 Overview u 3.2 Using C++ functions  Passing arguments  Header files & libraries u Writing C++ functions  Prototype  Definition.
CHAPTER 2 PART #3 C++ INPUT / OUTPUT 1 st Semester King Saud University College of Applied studies and Community Service CSC1101 By: Fatimah.
Chapter 3: Input/Output. Objectives In this chapter, you will: – Learn what a stream is and examine input and output streams – Explore how to read data.
1 COMS 261 Computer Science I Title: Functions Date: October 24, 2005 Lecture Number: 22.
Prof. amr Goneid, AUC1 CSCE 110 PROGRAMMING FUNDAMENTALS WITH C++ Prof. Amr Goneid AUC Part 9. Streams & Files.
File Processing Files are used for data persistance-permanent retention of large amounts of data. Computer store files on secondary storage devices,such.
Course Title Object Oriented Programming with C++ instructor ADEEL ANJUM Chapter No: 03 Conditional statement 1 BY ADEEL ANJUM (MSc-cs, CCNA,WEB DEVELOPER)
Computer Science: A Structured Programming Approach Using C1 Objectives ❏ To understand the basic properties and characteristics of external files ❏ To.
1 8/30/06CS150 Introduction to Computer Science 1 Your First C++ Program.
CSE 232: Moving Data Within a C++ Program Moving Data Within a C++ Program Input –Getting data from the command line (we’ve looked at this) –Getting data.
نظام المحاضرات الالكترونينظام المحاضرات الالكتروني I/O and File management Concept of streams. cin and cout objects. C++stream classes. Unformatted I/O.
Week 13 - Friday.  What did we talk about last time?  Server communications on a socket  Function pointers.
Chapter 3: Input/Output. Objectives In this chapter, you will: – Learn what a stream is and examine input and output streams – Explore how to read data.
Introduction Every program takes some data as input and generate processed data as out put . It is important to know how to provide the input data and.
Lecture 3: Getting Started & Input / Output (I/O)
CS212: Object Oriented Analysis and Design
Chapter 15 - C++ As A "Better C"
Bill Tucker Austin Community College COSC 1315
Examples (D. Schmidt et al)
Chapter 1.2 Introduction to C++ Programming
Introduction to C++ (Extensions to C)
Topic Pre-processor cout To output a message.
What Actions Do We Have Part 1
Chapter 1.2 Introduction to C++ Programming
Chapter 7 Text Input/Output Objectives
Chapter 7 Text Input/Output Objectives
Objectives Identify the built-in data types in C++
Basic Input and Output Operations
C++ History C++ was designed at AT&T Bell Labs by Bjarne Stroustrup in the early 80's Based on the ‘C’ programming language C++ language standardised in.
Chapter 2 part #3 C++ Input / Output
CS 1430: Programming in C++ Turn in your Quiz1-2 No time to cover HiC.
From lab 1 Using cs lab machines (including remote)
7 Arrays.
IO Overview CSCE 121 J. Michael Moore
More About Data Types & Functions
Chapter 3: Input/Output
CS150 Introduction to Computer Science 1
CMSC202 Computer Science II for Majors Lecture 03 – Arrays and Functions Dr. Katherine Gibson Based on slides by Chris Marron at UMBC.
7 Arrays.
Arrays Arrays A few types Structures of related data items
Chapter 2 part #3 C++ Input / Output
C++ Programming Basics
Chapter 1 c++ structure C++ Input / Output
IO Overview CSCE 121 Strongly influenced by slides created by Bjarne Stroustrup and Jennifer Welch.
4.1 Introduction Arrays A few types Structures of related data items
Programming Fundamental-1
Presentation transcript:

Spring 2018 http://cs.binghamton.edu/~iwobi/CS240C

week 1 - Introduction Goals Understand course organization, requirements and expectations Overview of course Introduction to c++ Functions Streams

Course home page http://cs.binghamton.edu/~iwobi/CS240C Textbook Cplusplus.com Listserv Grading Work load expectation Academic honesty

Assignment from zybook Before 11:30 on Thursday (Jan. 18) complete exercises from: Ch. 1 to 5 Ch. 7 (sections 1 and 2) Completion of sections not marked optional will count towards grade Optional sections cover material that has been covered before It is assumed that you know this material

Data structures plus algorithms == ???????

Containers A container is a collection of like elements/items (data structure) How are elements related to each other? What are the basic container operations (algorithms)? How are the elements stored in memory (implementation)? How do we measure the efficiency of container operations?

How are elements related to each other? Linear Hierarchical Graph membership

How are elements related to each other? Linear Hierarchical Graph membership

What are the basic container operations (algorithms)? Add an element By position By value Remove an element Retrieve an element

How are the elements stored in memory? Contiguous storage (array) Non-continuous storage (linked) combination

How are the elements stored in memory? Contiguous storage (array) Non-continuous storage (linked) combination

How do we measure the efficiency of container operations?

What are the building blocks of a program?

Functions and classes C program made up of functions Java program made up of classes C++ program made up of functions and classes

Where do functions and classes come from?

functions and classes can come from Part of the language (built in) A library C++ standard library Other libraries Programmer defined

A function is a black box caller behavior

How does a function communicate with its caller?

C++ parameter passing By value (type param-name) Parameter is a copy of the argument Argument cannot be changed By reference (type & param-name) Parameter is a reference to the argument Changing parameter changes the argument By const reference (const type & param-name) Compiler will not allow change to a parameter Used to prevent copy of argument being made Return can be by value or by reference

caller A1 A2 v1 v2 called (A1, A2) called (P1, P2) v1 P1 P2

C++ program organization

Function prototypes return-type function-name(parameter-list); // input: describe input parameters // output: describe value(s) returned // side effects: describe external I/O (if any) Prototype describes what, not how

What are side effects?

Side effects External input Keyboard File External output terminal Global variables Defined at file level (not inside a function or class) Do not use

Assignment from zybook Before 11:30 on Tuesday (Jan. 23) Complete exercises from: Ch. 6 Ch. 7 (sections 3 to 8) Do zylabs found in Ch.29 (sections 1 and 2)

Some differences (java and C++) No stand alone functions in java Details for defining a class Java has automatic Garbage collection C++ objects are values, java objects are references Direct vs indirect addressing Java is interpreted; C++ is compiled

Value vs reference If a variable/object is a value Name of the variable/object represents the memory location of the value Direct addressing If a variable/object is a reference Name of the variable/object represents the memory location which contains the memory location of the value Indirect addressing

Java C++ C++ JAVA string name = “C++”; string name = new string (“java”); name name C++ JAVA

What happens? “C++” “JAVA” String Name2 = name; String Name2 = name;

What happens? “C++” “C++” “JAVA” String Name2 = name;

Compiled vs interpreted languages

C++ Compiler used in cs240c Gcc Available on all cs lab machines Can access remotely All programs written for CS240C must compile and run using GCC on the CS lab machines

Some differences (C and C++) I/O Parameter passing Strings Templates classes

C++ uses streams for I/O A stream is a sequence of characters An Input stream can come from the keyboard (terminal) Text files can also be used as input streams Programs produce output streams that can be sent to: THE Screen (terminal) A text file

Programs using terminal I/O Need to #include <iostream> Iostream is a header file from the C++ standard library Defines objects that can be used for I/O Cout cin

Using cout Cout is an object of type(class) ostream Is connected to the stream of characters being sent to the terminal at run-time Insertion operator (<<) sends character representation of values to the output stream Ex: Cout << value1 << “ “ << value2 << endl; Formatting of output can be controlled by manipulators

Using cin Cin is an object of type(class) istream Is connected to the stream of characters entered at the keyboard at run-time Extraction operator (>>) reads a sequence of non white space characters from the input stream and assigns a value (of the needed type) to a variable Ex: cin >> myInt >> mystring; What happens if the characters extracted are “34abc”?