Announcements Exam 2 Lecture Grades Posted on blackboard

Slides:



Advertisements
Similar presentations
1 Pointers and Strings Section 5.4, , Lecture 12.
Advertisements

Pass by Value. COMP104 Pass by Value / Slide 2 Passing Parameters by Value * A function returns a single result (assuming the function is not a void function)
C++ provides the following classes to perform output and input of characters to/from files: ofstream: Stream class to write on filesofstream ifstream:
More on Functions Programming. COMP104 Lecture 19 / Slide 2 Passing Parameters by Reference l To have a function with multiple outputs, we have to use.
1 CS 105 Lecture 12 Pass- By-Reference, 2-D Arrays Version: Wed, Apr 20, 2011, 6:25 pm.
Functions:Passing Parameters by Value Programming.
What If? Write a program that prompts for the names and locations of 1000 employees. Store the information in the program for later use.
File Review Declare the File Stream Object Name –ofstream for output to file –ifstream for input from file Associate a File Name with the File Stream Object.
Upcoming Events Project Check Due Next Week in Lab –Phase I –main(), menu() Functions and Reading in File –Stub Functions Last Lectures Next Week –Project.
Announcements Final Exam:. Review Passing Arrays as Parameters Pass Array Name into Function int intArray[100]; func(intArray); Accept into Function as.
C++ Functions. 2 Agenda What is a function? What is a function? Types of C++ functions: Types of C++ functions: Standard functions Standard functions.
C++ function call by value The call by value method of passing arguments to a function copies the actual value of an argument into the formal parameter.
ITEC 320 C++ Examples.
ECE 264 Object-Oriented Software Development Instructor: Dr. Honggang Fall 2012 Lecture 8: File I/O; Introduction to classes.
C++ Functions. Objectives 1. Be able to implement C++ functions 2. Be able to share data among functions 2.
Tracing through E01, question 9 – step 1 // p02.cc P. Conrad, for CISC181 07S // Exam question for E01 #include using namespace std; void mysteryFunction(int.
1 Cannon_Chapter9 Strings and the string Class. 2 Overview  Standards for Strings  String Declarations and Assignment  I/O with string Variables 
Exceptions in C++. Exceptions  Exceptions provide a way to handle the errors generated by our programs by transferring control to functions called handlers.
Functions BICSE-6A Mr. Naeem Khalid Lecturer, Dept. of Computing.
FUNCTIONS (C) KHAERONI, M.SI. OBJECTIVE After this topic, students will be able to understand basic concept of user defined function in C++ to declare.
Functions Input and output Lecture 2. Constants #define – is a preprocessor directive Most common use.
Hank Childs, University of Oregon
Pointers What is the data type of pointer variables?
CS31 Discussion Jie(Jay) Wang Week6 Nov.4.
Topic Pre-processor cout To output a message.
File Processing in C++ Data is stored in files so that it may be retrieved for processing when needed.
CMSC 202 Lesson 2 C++ Primer.
EECs 183 Discussion 10 Hannah Westra.
Command Line Arguments
Multi-dimensional Array
Parallel Arrays Parallel array =>Two or more arrays with the same number of elements used for storing related information about a collection of data. Example:
What If? Write a program that prompts for the names and locations of 1000 employees. Store the information in the program for later use.
Dynamic Memory Allocation Reference Variables
Programming -2 برمجة -2 المحاضرة-5 Lecture-5.
Initializing Arrays char [] cArray3 = {'a', 'b', 'c'};
Variables with Memory Diagram
Peer Instruction 6 Java Arrays.
Object-Oriented Programming (OOP) Lecture No. 36
C++ fundamentals Lecture 1, Chapter 2 – pp /22/2018 Y K Choi.
Announcements General rules about homeworks
Chapter 5 Function Basics
Starting Out with C++: From Control Structures through Objects
Pointers & Functions.
Anatomy of a Function Part 1
Programming with Data Files
Code::Block vs Visual C++
File Review Declare the File Stream Object Name
Arrays Syntax: type variableName[size];
Arrays of Objects // The following does NOT create memory for
File Processing in C++ Data is stored in files so that it may be retrieved for processing when needed.
CS150 Introduction to Computer Science 1
Announcements Homework 1 will be assigned this week,
CS150 Introduction to Computer Science 1
CHAPTER 2 Arrays and Vectors.
Function Defaults C++ permits functions to be declared with default values for some, or all, of its parameters Allows for the function to be called without.
Fundamental Programming
COMS 261 Computer Science I
CHAPTER 2 Arrays and Vectors.
Announcements General rules about homeworks
Pointers and dynamic objects
Using string type variables
Instructor: Dr. Michael Geiger Spring 2019 Lecture 13: Exam 1 Preview
Pointers & Functions.
Strings Skill Area 313 Part C
Anatomy of a Function Part 1
CS31 Discussion 1D Winter19: week 4
Instructor: Dr. Michael Geiger Spring 2017 Lecture 12: Exam 1 Preview
EECE.3220 Data Structures Instructor: Dr. Michael Geiger Spring 2019
EECE.3220 Data Structures Instructor: Dr. Michael Geiger Spring 2019
What If? Write a program that prompts for the names and locations of 1000 employees. Store the information in the program for later use.
Presentation transcript:

Announcements Exam 2 Lecture Grades Posted on blackboard Project posted on blackboard under Tasks Final Exam:

Project Posted on blackboard under Tasks Due Wednesday of Finals week at Noon CDT Hand in to your TA (NOT me!) .cpp (source code), .txt (Data file runwaycs105.txt), .doc (Analysis)

Don’t’s No Working Together Write Your Own Code!!! Checked by Supercomputer May be Called in to Discuss Program Last Term – 10 Investigated, 7 0s, 1 probation Nine terms (74 investigated, 44 received 0s)

Initializing Arrays int main() { char cArray3[5] = {'a', 'b', 'c'}; int iArray[] = {1, 2, 3, 4}; int iArray2[10] = {10, 13, 15, 17}; double dArray[] = {3.4, 5.67e4}; double dArray1[5] = {6.7, 7.8, 9.5}; }

Initializing string Arrays #include <string> using namespace std; int main() { string sArray[] = {"one", "two", "three"}; cout << sArray[0]; }

Two Dimensional Arrays char cArray[10][20]; int iArray[100][50]; cArray[0][0] = ‘a’; cArray[0][1] = ‘b’; cArray[9][19] = ‘x’; iArray[0][0] = 99; iArray[1][5] = 135; iArray[99][49] = 0;

Function Parameters (Arguments) May Pass as Many Parameters as Necessary to Function A Copy of the Value of the Parameter Is Passed to the Function Changing the Value of the Parameter in the Function Does Not Affect the Value of the Original Variable This Is Called Pass-by-Value Arrays are NOT Pass-by-Value

Passing Arrays as Parameters Pass Array Name into Function int intArray[100]; func(intArray); Accept into Function as an Array with No Set Size int func( int array[] ) Changes to Array in Function *will* Update Original Array This is called Pass-by-Reference

Passing Arrays Example void func(int passedArray[]); main() { int intArray[5]; for(int i = 0; i < 5; i++) intArray[i] = i; cout << intArray[0]; func(intArray); } void func(int passedArray[]) passedArray[0] = 1000;

getline() Function Interface Function to an Input Stream Object (i.e., a File Open for Reading) Reads an Entire Line from the File Including White Space Example: ifstream inputFile; string lineOfText; inputFile.open(“datafile”); getline(inputfile,lineOfText);

getline() Function #include <string> #include <iostream> using namespace std; int main() { string phrase; cout << "Enter a phrase: "; getline(cin, phrase); cout << phrase << endl; return(0); }