cs16wk03c

cs16wk03c - Operations depend on types Operations e.g.,...

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

View Full Document Right Arrow Icon
Operations depend on types Operations depend on types e.g., binary operation: e.g., binary operation: a a op op b b z If a and b are same type: (1) perform op based on rules of that type, and (2) return result of that type z If a and b are different types: (0) make a copy of “lower” value promoted to “higher” type – Then (1), (2) as above using copy and higher type item – Means result is higher type (see high to low types on p. 44) z Cast operator – specifies type of copied value double d = 2.5; int n = 10 / (int)d; /* Q. What does n equal? */
Background image of page 1

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

View Full DocumentRight Arrow Icon
Technique: linear interpolation Technique: linear interpolation z Text pp. 56-59 describes idea of “similar triangles” z Program chapter2_2 - applies it to seawater temperatures …demo03/ p2-2.c
Background image of page 2
Functions for characters Functions for characters z Alternatives to scanf , printf with "%c" : int c = getchar (); putchar (c); /* one character at a time */ z Ways to make a copy of a character: tolower (c) , toupper (c) z Ways to ask about a character’s kind: islower (c) , isupper (c) , isalpha (c) , isdigit (c) , isxdigit (c) , … Try it!
Background image of page 3

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

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

This note was uploaded on 03/01/2011 for the course CMPSC 16 taught by Professor Costanzo during the Spring '11 term at UCSB.

Page1 / 12

cs16wk03c - Operations depend on types Operations e.g.,...

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

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