This preview has intentionally blurred sections. Sign up to view the full version.
View Full DocumentThis preview has intentionally blurred sections. Sign up to view the full version.
View Full DocumentThis preview has intentionally blurred sections. Sign up to view the full version.
View Full Document
Unformatted text preview: CME/Energy 211 Margot Gerritsen Shela Aboud Emmet Caulfield Lecture Overview • Type Categories and Constants • Control Statements – Selection Statements: if and switch – Iteration Statements: for , while and dowhile – Jump Statements: return , goto , break and continue Type Categories • Basic (data) types – int , char , float , double , void • Floating types – float , double , long double • Enumeration types – a set of named integer types • Union types – a set of overlapping nonempty objects • Aggregate types – array and structure types • Integral types – the set char , int and enum types • Arithmetic types – integral and floating types • Scalar types – arithmetic and pointer types • Derived declaration types – array, function and pointer types • Incomplete types – objects that lack enough information to determine their size • lvalue – an object type or incomplete type other than void ; basically an identifier that can appear on the LHS of an assignment In addition to the basic data type of a variable, objects and functions can be grouped to define other categories of type, i.e., derived types . Constants  Summary • Integer Constant – decimal constant (base 10) – initial value is nonzero, uses characters 09; octal constant (base 8) – initial value is zero, uses characters 07; hexadecimal constant (base 16) – initial value is 0x or 0X, uses characters 09,af, or AF • Character Constant – a character or one of the nongraphic characters represented by the escape sequences enclosed in a set of single quotes • Floating Constant – composed of a significant part and an exponential part. The significant portion is a sequence of number 09 to represent the whole number followed by a radix point (.) and a sequence of numbers representing the fractional part • Enumeration Constant – defined type int The value of a constant is in the range of representable values for its type (i.e., defined by its type). The Semicolon and Blocks Semicolon In C, the semicolon is a always ends a statement . An expression (e.g., x = 0 or i++ ) can become a statement when followed by a semicolon (e.g., x=0; or i++;) A semicolon by itself is a null statement (and performs no operation) Braces Braces are used to group declarations and statements together into a block, which is then equivalent to a single statement ....
View
Full
Document
This note was uploaded on 06/17/2010 for the course CME 211 taught by Professor Staff during the Winter '10 term at Stanford.
 Winter '10
 Staff

Click to edit the document details