MidTermReview-1

MidTermReview-1 - ECE 3090 Software for Engineering Systems...

Info iconThis preview shows pages 1–9. Sign up to view the full content.

View Full Document Right Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: ECE 3090 Software for Engineering Systems Prof. Hongwei Wu School of Electrical and Computer Engineering Georgia Institute of Technology (Savannah) Midterm Review Session ¡ Data types ¡ Variable definition, initialization, assignment, and scope. ¡ cout, cin, get, getline ¡ File operations ¡ Operators and precedence: arithmetic, relational, logical, increment, decrement ¡ if… else if … else statement ¡ switch ¡ Loop ¡ Function ¡ Array and vector ¡ Pointer ¡ Character array and string ¡ Image Processing Data Types ¡ Data types ¢ integer ¢ char: enclosed by single quote marks. ¢ character string (char array): null terminator, double quote marks ¢ floating-point: two forms of representations (fixed point vs. E notation) ¢ bool ¢ vector ¢ string ¡ Size and range ¢ sizeof ¢ Underflow and overflow ¡ Data type ranking and (automatic) type coercion ¢ long double > double > float > unsigned long > long > unsigned int > int ¢ chars , shorts , and unsigned shorts are automatically converted to int ; ¢ When an operator works with two values of different data types, the lower ranking value is promoted to the type of the higher-ranking value. ¢ When the final value of an expression is assigned to a variable, it will be converted to the data type of that variable. ¡ Data type casting: manual data coercion ¢ static_cast< data type >( variable / literal ) Variable definition, initialization, assignment, and scope ¡ data_type variable_name ; ¡ Assigning values to variables can be done the same time the variables are defined (initialization), or after. ¡ Special attention to character arrays and strings ¢ Initialization ¡ char charArray [40] = “Hello, world”; OK ¢ Cannot use =, but strcpy to assign values to char arrays ¡ char charArray [40]; ¡ charArray = “Hello, world”; WRONG ¡ strcpy(charArray, “Hello, world”); OK ¢ Can use = to assign values to strings ¡ string charString; ¡ charString = “Hello, world”; OK ¡ The scope of a variable can be the entire program or only part of the program (e.g., loop, function) Stream operators (<< and >>), get, and getline ¡ #include <iostream> ¡ Standard output object (cout) and standard input object (cin) ¡ cin: space (one or multiple) to separate numbers and press [Enter] after the last number is entered ¡ Use cin.get() to read the next character entered even it is blank, tab or [Enter] ¡ Use cin.getline() to read an entire line of input. ¡ The stream extraction operator >> returns true when a value is successfully read, false otherwise File Operations ¡ #include <fstream> ¡ File stream types: ifstream, ofstream, fstream ¡ Define file stream objects ¢ ifstream inputFile; ¢ ofstream outputFile; ¡ Open files ¢ inputFile.open(“inventory.data”); ¢ outputFile.open(“report.txt”); ¡ Test for file open errors ¢ if (!inputFile) ¢ if (!outputFile) ¡ Stream operators >> and << can be used with file stream objects to read or write data ¢ inputFile >> partNumber; ¢ outputFile << “Inventory Report”; ¡ Close files ¢ inputFile.close(); ¢ outputFile.close(); Arithmetic Operators...
View Full Document

This note was uploaded on 10/24/2009 for the course ECE 3090 taught by Professor Staff during the Fall '08 term at Georgia Tech.

Page1 / 29

MidTermReview-1 - ECE 3090 Software for Engineering Systems...

This preview shows document pages 1 - 9. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online