Presentation is loading. Please wait.

Presentation is loading. Please wait.

Announcements Exam 2 Lecture Grades Posted on blackboard

Similar presentations


Presentation on theme: "Announcements Exam 2 Lecture Grades Posted on blackboard"— Presentation transcript:

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

2 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)

3 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)

4 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}; }

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

6 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;

7 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

8 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

9 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;

10 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);

11 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); }


Download ppt "Announcements Exam 2 Lecture Grades Posted on blackboard"

Similar presentations


Ads by Google