APS105 Winter Jonathan Deber jdeber -at- cs -dot- toronto -dot- edu. Lecture 5 January 25, 2012
|
|
- Elmer McDonald
- 5 years ago
- Views:
Transcription
1 APS105 Winter 2012 Jonathan Deber jdeber -at- cs -dot- toronto -dot- edu Lecture 5 January 25, 2012
2 Today Reading Input More Conversion Specifiers 2
3 Constants and Style Magic Number Bad Style!"#$%&#'()*+',!"#$%&#'-.)/0)12-/)23'456!"#$%&#'-71+-8'96 Bad Style Evil 3
4 Style Two audiences: Compiler Other people (includes yourself in the future) 4
5 ''''''''''''%&:'''''''''''''''<M4BN'''''''''''''''''''O'M'''''''''4BN'''OPQ 'PR'''DDD'''DDD'''.12S).LTD'''EIQHLFAUU'''UV6WNXYFU'''UXU'''UXU'''UZU'''UTV Y<U'''UYU'''U:U'''''''''U[U'''''''''U\U'''''''''U;U'''''''''U&U'''''''''P]M 'OA'''U^U'''U?:_$:"`U'''UX"E_`#;U'''U"X_aE_&&T$UKLL'''LLL'''LKU:Vb,bV:UDEc %&:''';'P'''''''''%&:'''''''''\de'''''''''''''''''''''\f<'''M;O'''''''''M\g '6O'''hA4P<M;OM\g6O'i''',jf.OM\g6'''O'i'''6BOOdkbkbD;f<M;'''g6OM\OhA6'''P<M ';g'''''''''''''''6om'''\oi''''''''',jf'''''''''''''''.g6'''om\'''''''''oi 6BO'''OdkbkbD\G'''4BB'''f<M''';OM\l6OhAjP<M;OM\l6Oi''',jf'''.OM'''\l6Oi6BOO dkb'''''''''kbd''''''''';'g'''''''''''''''4bb'''f<m''';l6'''''''''om\'''oha,p<m;l6om'''\oi,jf.l6om\oi6boodkbkbd.om'''\oi'''6bo'''oddme;ceiqhlxde'''h#:;h& 'LX'''''''''''''''fE;'''cXl'''''''''6di'''''''''6fX'''MbO'''''''''''''''llk XMb'''Ogg'''k6D'''m"c'''%&:''';'P'''%&:KLLK\P'''%&:KLLKYP'''%&:'''nde'''%&: %&:'''$A8'''''''''''''''gco'''JJ6'''dDD'''''''''''''''TI%F#c;_A'''''''''Yde 'OM'''''''''''''''\Oi'''N,f'''Nbk''''''''',Nd'''''''''D%$'''''''''c<M''';OM 'c\'''_an'''''''''de$'''jab'''''''''f;'''lapp'''''''''''''''$ga'''''''''8kb 'OM'''''''''''''''''''''\Oi'''''''''6Nd'''eEc''';P\'''''''''''''''''''''dD ''D'''H#:;H&DDDmmmm^c'''%&:KLLKQP'''%&:'''Rde'''m#c'''%&:KLLKnP%&:KLLK''Yde %&:'''''''''''''''%'D'''''''''$>H'''''''''c%A'''''''''QD%'''''''''''''''GAQ lpd%lld"cnpyp%prdp"cnpyp%prlqdd$>hc%ard%garlqd%lld"cnpypqp%dp"cnpypql'''pp% 'dd'''''''''''''''''''''ddd'''''''''ddd'''''''''ddd'''''''''''''''ddd'''d ddm'''''''''''''<q%&c'''''''''%&:'''''''''''''''r'p'''eiqh''''''''''''''l=m ''O'''de(1q3L$A'''$>?#&crAA6fUQHQEI&%"5EUKLLK'''k=M'''6OPUHUdD%&:KLLKYPnPEP ''c'''9bbp''9bb'''''''''''''''d'd'''$>h'''''''''cya'''4bb'''d'y'''jab'''dygg arachnid by ''c'''cea'''''''''''''''''''''''''''$s#:e'c$d'''dl6d''''''''''''''''''''e%$c Nick Johnson, IOCCC 2004
6 ">'e ''''\lld ''''<\TQ""EI'cTP'nPY'P<MYOM'nOi'94f'<MY'OMn'O'i'6Nf'bh ''''EAAb6N9ii_c<MYOMnl6Oi6Ndfnllk'bD ''''E'AA'66C'ii_'c<M'YOM'ng'6Oi'6Nd'fnggkbD ''''D ''''E'AACW'ii_c<MYg6OMnOi6NdfYggkbD ''''EAA6bbii_c<MYl6'OM'nOi'6Nd'f'Y'llkb'D ''''%$c'eaa'9g'6l6'd'e ''''''''#&"T%&c'dD ''''''''D ''''''''H#:;H&cbd'D ''''m ''''Y'gQGBfQJpg'BfQgApgBkcQAbdkbD ''''Y'gQJ'pgBfQG4BB'gpL'4fQ'lApgBkcQA4BNgpdkbD ''''ngrgbfrjqgbfrgaqgbkcr'abd'kbd ''''ngrjqgbfrg4bbgq'l4frla'qgb'kcr'a4bngqd'kbd ''''#cypndd ''''%$c<myomnoin,drh#qzd m'ti%f#cceas#:eicdd_ag6dd arachnid by Nick Johnson, IOCCC
7 Good Variable Names Be clear (and use conventions) Don t abbreviate too much &@ vs. &;<p:;"#&:@ Don t be too verbose &;<R#H)$p:;"#&:@-IQ:vH#1&-I#=FQ@@v:-I%@-%<# Use an initial comment %&:'&;<p:;"#&:@d''kk'2;<r#h'>$'@:;"#&:@'#&h>ff#"'%&'efq@@5 It takes practice 7
8 Reading Input 8
9 @EQ&$ Reads formatted input address of operator Takes input, interprets and stores it Usually paired with?h%&:$ prompt 9
10 Multiple Variables Multiple variables separated by whitespace ####%" T%":Ik I#%sI:k "#?:Ik b b b 4b 9b,b 10
11 Multiple Variables Multiple variables separated by whitespace ####%" T%":Ik I#%sI:k "#?:Ik b b b 4b 9b,b!" $" %"!" $" %" 10
12 Invalid Input T%":Ik I#%sI:k "#?:Ik b b b 4 11
13 Invalid Input t4t t't tqt t't t9t t't t,t t t T%":Ik b I#%sI:kb "#?:Ik b 12
14 Invalid Input t4t t't tqt t't t9t t't t,t t t T%":Ik b I#%sI:kb "#?:Ik b 12
15 Invalid Input T%":Ik b I#%sI:kb "#?:Ik b 4 t4t t't tqt t't t9t t't t,t t t 12
16 Invalid Input T%":Ik b I#%sI:kb "#?:Ik b 4 t4t t't tqt t't t9t t't t,t t t 12
17 Invalid Input t4t t't tqt t't t9t t't t,t t t T%":Ik I#%sI:k "#?:Ik Yk nk b b b b b 4 12
18 Invalid Input T%":Ik I#%sI:k "#?:Ik 4'' '' '' 13
19 Format Strings Other characters can be present 14
20 Format Specifiers %&: w" ">;RF# wf$ (different than?h%&:$!) char %c Doesn t skip whitespace 15
21 @EQ&$ does not skip whitespace for we $" %"!" $" %" T%":Ik 4b I#%sI:k9b "#?:Ik,b '() <%""F#k x v S 16
22 @EQ&$ does not skip whitespace for we $" %"!" $" %" T%":Ik 4b I#%sI:k9b "#?:Ik,b '() ' ( ) $%H@:k x <%""F#kv FQ@:k S 16
23 Skipping Whitespace ' ( ) $%H@:k x <%""F#kv FQ@:k S ' ( ) $%H@:k x <%""F#kv FQ@:k S 17
24 ' ' <%""F#k' ' txt t t 18
25 x' ' <%""F#k' ' txt t t 18
26 x' ' <%""F#k ' ' txt t t 18
27 x' ' <%""F#k ' ' txt t t 18
28 x' ' ) <%""F#k ' FQ@:k ' txt t t tst t t 18
29 x' ' ) <%""F#k ' FQ@:k S' txt t t tst t t 18
30 x' ' ) <%""F#k ' FQ@:k S' txt t t tst t t 18
31 @EQ&$ Is a bit awkward Not really designed for human use We ll see some better alternatives later 19
32 Customizing?H%&:$ Conversion Specifiers 20
33 %&:'%'A'9D?H%&:$cUhw"h'V&UP'%dD?H%&:$cUhwj54"h'V&UP'%dD?H%&:$cUhwj"h'V&UP'%dD?H%&:$cUhw54"h'V&UP'%dD '''' ">;RF#'"'A',5BNWD?H%&:$cUhwsh'V&UP'"dD?H%&:$cUhwj54sh'V&UP'"dD?H%&:$cUhwjsh'V&UP'"dD?H%&:$cUhw54sh'V&UP'"dD h9h' h''''''b9h' h'''''''9h' hb9h h,5bnwh' h''''',5nh' h''',5bnwh' h,5nh 21
34 wj54" width type precision 22
35 Width Same meaning for all conversion specifiers Indicates the minimum number of characters to use %&:'%'A'9,BD?H%&:$cUhw"h'V&UP'%dD?H%&:$cUhwj"h'V&UP'%dD?H%&:$cUhw4"h'V&UP'%dD ">;RF#'"'A',5BNWD?H%&:$cUhwsh'V&UP'"dD?H%&:$cUhwjsh'V&UP'"dD?H%&:$cUhw4sh'V&UP'"dD h9,bh' h'''''9,bh' h9,bh h,5bnwh' h''',5bnwh' h,5bnwh 23
36 Precision Different specifiers interpret it differently w" ws w$ 24
37 Precision (w") For w", it s the minimum number of digits %&:'%'A'9,BD?H%&:$cUhw"h'V&UP'%dD?H%&:$cUhw5j"h'V&UP'%dD?H%&:$cUhw54"h'V&UP'%dD h9,bh' hbbbbb9,bh' h9,bh 25
38 Precision (ws) For ws, it s the maximum number of significant digits ">;RF#'"'A',5BNWD?H%&:$cUhwsh'V&UP'"dD?H%&:$cUhw5jsh'V&UP'"dD?H%&:$cUhw54sh'V&UP'"dD ">;RF#'#'A'45CCWC4,Bj#jD?H%&:$cUhwsh'V&UP'#dD?H%&:$cUhw56bsh'V&UP'#dD?H%&:$cUhw5,sh'V&UP'#dD h,5bnwh' h,5bnwh' h,5nh h45ccwc4#lbjh' h4ccwc4,bjh' h45ccj#lbjh' 26
39 Precision (w$) For w$, it s the exact number of digits after the decimal ">;RF#'"'A',5BNWD By default, w$ means w5n$ ">;RF#'#'A'45CCWC4,Bj#jD?H%&:$cUhw$h'V&UP'"dD?H%&:$cUhw$h'V&UP'#dD?H%&:$cUhw5j$h'V&UP'"dD?H%&:$cUhw5j$h'V&UP'#dD?H%&:$cUhw56$h'V&UP'"dD?H%&:$cUhw56$h'V&UP'#dD h,5bnwbbbh' h4ccwc4,bj5bbbbbbh ' h,5bnwbbbbbh' h4ccwc4,bj5bbbbbbbbh ' h,5nh' h4ccwc4,bj5bh 27
APS105 Winter Jonathan Deber jdeber -at- cs -dot- toronto -dot- edu. Lecture 24 March 16, 2012
APS105 Winter 2012 Jonathan Deber jdeber -at- cs -dot- toronto -dot- edu Lecture 24 March 16, 2012 Today (Even More) Dynamic Memory Allocation 2 Dynamic Memory Allocation!"##$%&' and friends 3 Automatic
More informationCPE 101, reusing/mod slides from a UW course (used by permission) Lecture 5: Input and Output (I/O)
CPE 101, reusing/mod slides from a UW course (used by permission) Lecture 5: Input and Output (I/O) Overview (5) Topics Output: printf Input: scanf Basic format codes More on initializing variables 2000
More informationAdvanced C Programming Topics
Introductory Medical Device Prototyping Advanced C Programming Topics, http://saliterman.umn.edu/ Department of Biomedical Engineering, University of Minnesota Operations on Bits 1. Recall there are 8
More informationAnnouncements. Working on requirements this week Work on design, implementation. Types. Lecture 17 CS 169. Outline. Java Types
Announcements Types Working on requirements this week Work on design, implementation Lecture 17 CS 169 Prof. Brewer CS 169 Lecture 16 1 Prof. Brewer CS 169 Lecture 16 2 Outline Type concepts Where do types
More informationDisplay Input and Output (I/O)
2000 UW CSE CSE / ENGR 142 Programming I isplay Input and Output (I/O) -1 Writing Useful Programs It s hard to write useful programs using only variables and assignment statements Even our Fahrenheit to
More informationCS 31: Introduction to Computer Systems. 03: Binary Arithmetic January 29
CS 31: Introduction to Computer Systems 03: Binary Arithmetic January 29 WiCS! Swarthmore Women in Computer Science Slide 2 Today Binary Arithmetic Unsigned addition Subtraction Representation Signed magnitude
More informationCS102: Standard I/O. %<flag(s)><width><precision><size>conversion-code
CS102: Standard I/O Our next topic is standard input and standard output in C. The adjective "standard" when applied to "input" or "output" could be interpreted to mean "default". Typically, standard output
More informationCS1 Recitation. Week 1
CS1 Recitation Week 1 Admin READ YOUR CS ACCOUNT E-MAIL!!! Important announcements, like when the cluster will be unavailable, or when you need to reset your password. If you want to forward your e-mail:
More informationCS558 Programming Languages Winter 2018 Lecture 4a. Andrew Tolmach Portland State University
CS558 Programming Languages Winter 2018 Lecture 4a Andrew Tolmach Portland State University 1994-2018 Pragmatics of Large Values Real machines are very efficient at handling word-size chunks of data (e.g.
More informationScientific Computing. Error Analysis
ECE257 Numerical Methods and Scientific Computing Error Analysis Today s s class: Introduction to error analysis Approximations Round-Off Errors Introduction Error is the difference between the exact solution
More informationOverview (4) CPE 101 mod/reusing slides from a UW course. Assignment Statement: Review. Why Study Expressions? D-1
CPE 101 mod/reusing slides from a UW course Overview (4) Lecture 4: Arithmetic Expressions Arithmetic expressions Integer and floating-point (double) types Unary and binary operators Precedence Associativity
More informationCS 31: Intro to Systems Binary Arithmetic. Kevin Webb Swarthmore College January 26, 2016
CS 31: Intro to Systems Binary Arithmetic Kevin Webb Swarthmore College January 26, 2016 Reading Quiz Unsigned Integers Suppose we had one byte Can represent 2 8 (256) values If unsigned (strictly non-negative):
More informationTypes, Values, Variables & Assignment. EECS 211 Winter 2018
Types, Values, Variables & Assignment EECS 211 Winter 2018 2 Road map Strings and string I/O Integers and integer I/O Types and objects * Type safety * Not as in object orientation we ll get to that much
More informationProgramming with C++ as a Second Language
Programming with C++ as a Second Language Week 2 Overview of C++ CSE/ICS 45C Patricia Lee, PhD Chapter 1 C++ Basics Copyright 2016 Pearson, Inc. All rights reserved. Learning Objectives Introduction to
More informationC++ Basics. Lecture 2 COP 3014 Spring January 8, 2018
C++ Basics Lecture 2 COP 3014 Spring 2018 January 8, 2018 Structure of a C++ Program Sequence of statements, typically grouped into functions. function: a subprogram. a section of a program performing
More informationCS 220: Introduction to Parallel Computing. Beginning C. Lecture 2
CS 220: Introduction to Parallel Computing Beginning C Lecture 2 Today s Schedule More C Background Differences: C vs Java/Python The C Compiler HW0 8/25/17 CS 220: Parallel Computing 2 Today s Schedule
More informationToday in CS161. Lecture #7. Learn about. Rewrite our First Program. Create new Graphics Demos. If and else statements. Using if and else statements
Today in CS161 Lecture #7 Learn about If and else statements Rewrite our First Program Using if and else statements Create new Graphics Demos Using if and else statements CS161 Lecture #7 1 Selective Execution
More informationCSE 341: Programming Languages
CSE 341: Programming Languages Winter 2005 Lecture 17 varargs and apply, implementing higher-order functions CSE341 Winter 2005, Lecture 17 1 Today: Some easy Scheme odds and ends Implementing higher-order
More informationLecture 05 I/O statements Printf, Scanf Simple statements, Compound statements
Programming, Data Structures and Algorithms Prof. Shankar Balachandran Department of Computer Science and Engineering Indian Institute of Technology, Madras Lecture 05 I/O statements Printf, Scanf Simple
More informationVARIABLES. 1. STRINGS Data with letters and/or characters 2. INTEGERS Numbers without decimals 3. FLOATING POINT NUMBERS Numbers with decimals
VARIABLES WHAT IS A VARIABLE? A variable is a storage location in the computer s memory, used for holding information while the program is running. The information that is stored in a variable may change,
More informationThese are notes for the third lecture; if statements and loops.
These are notes for the third lecture; if statements and loops. 1 Yeah, this is going to be the second slide in a lot of lectures. 2 - Dominant language for desktop application development - Most modern
More informationNumber systems and binary
CS101 Fundamentals of Computer and Information Sciences LIU 1 of 8 Number systems and binary Here are some informal notes on number systems and binary numbers. See also sections 3.1 3.2 of the textbook.
More informationAddress Class (Exercise) B A
Address Class (Exercise) Address Class 177.100.18.4 B 119.18.45.0 A 192.249.234.191 C 10.10.251.12 A 223.32.232.190 C 129.132.24.2 B 18.250.1.1 A 150.10.15.0 B 197.14.2.0 C 174.17.9.1 B 148.17.9.1 B 193.42.1.1
More informationChapter 11 Introduction to Programming in C
Chapter 11 Introduction to Programming in C C: A High-Level Language Gives symbolic names to values don t need to know which register or memory location Provides abstraction of underlying hardware operations
More information6.096 Introduction to C++
MIT OpenCourseWare http://ocw.mit.edu 6.096 Introduction to C++ January (IAP) 2009 For information about citing these materials or our Terms of Use, visit: http://ocw.mit.edu/terms. 6.096 Lecture 3 Notes
More informationCSCA08 Winter 2018 Week 3: Logical Operations, Design Recipe. Marzieh Ahmadzadeh, Brian Harrington University of Toronto Scarborough
CSCA08 Winter 2018 Week 3: Logical Operations, Design Recipe Marzieh Ahmadzadeh, Brian Harrington University of Toronto Scarborough Administrative Detail ex1 is up TT #1 and TT #2 info. can be found on
More informationStructured Programming Using C++ Lecture 2 : Introduction to the C++ Language. Dr. Amal Khalifa. Lecture Contents:
Structured Programming Using C++ Lecture 2 : Introduction to the C++ Language Dr. Amal Khalifa Lecture Contents: Introduction to C++ Origins Object-Oriented Programming, Terms Libraries and Namespaces
More informationCSE 374 Programming Concepts & Tools
CSE 374 Programming Concepts & Tools Hal Perkins Fall 2017 Lecture 8 C: Miscellanea Control, Declarations, Preprocessor, printf/scanf 1 The story so far The low-level execution model of a process (one
More informationJava Program Structure and Eclipse. Overview. Eclipse Projects and Project Structure. COMP 210: Object-Oriented Programming Lecture Notes 1
COMP 210: Object-Oriented Programming Lecture Notes 1 Java Program Structure and Eclipse Robert Utterback In these notes we talk about the basic structure of Java-based OOP programs and how to setup and
More informationCOMP-202: Foundations of Programming. Lecture 2: Java basics and our first Java program! Jackie Cheung, Winter 2016
COMP-202: Foundations of Programming Lecture 2: Java basics and our first Java program! Jackie Cheung, Winter 2016 Learn about cutting-edge research over lunch with cool profs January 18-22, 2015 11:30
More informationCS 177 Recitation. Week 1 Intro to Java
CS 177 Recitation Week 1 Intro to Java Questions? Computers Computers can do really complex stuff. How? By manipulating data according to lists of instructions. Fundamentally, this is all that a computer
More informationTopics Introduction to Microprocessors
Topics 22440 Introduction to Microprocessors C-Language Review (I) Important: : You will not learn how to code in C in this one lecture! You ll still need some sort of C reference. C Syntax Important Tidits
More informationWhat are the most likely declarations of "month" in the old and new versions of the program?
All multiple choice questions are equally weighted. You can generally assume that code shown in the questions is syntactically correct, unless something in the question or one of the answers suggests otherwise.
More informationIntroduction to Verilog HDL
Introduction to Verilog HDL Ben Abdallah Abderazek National University of Electro-communications, Tokyo, Graduate School of information Systems May 2004 04/09/08 1 What you will understand after having
More informationCS61C Machine Structures. Lecture 3 Introduction to the C Programming Language. 1/23/2006 John Wawrzynek. www-inst.eecs.berkeley.
CS61C Machine Structures Lecture 3 Introduction to the C Programming Language 1/23/2006 John Wawrzynek (www.cs.berkeley.edu/~johnw) www-inst.eecs.berkeley.edu/~cs61c/ CS 61C L03 Introduction to C (1) Administrivia
More informationSeparable Kernels and Edge Detection
Separable Kernels and Edge Detection CS1230 Disclaimer: For Filter, using separable kernels is optional. It makes your implementation faster, but if you can t get it to work, that s totally fine! Just
More informationChapter 11 Introduction to Programming in C
Chapter 11 Introduction to Programming in C C: A High-Level Language Gives symbolic names to values don t need to know which register or memory location Provides abstraction of underlying hardware operations
More informationCS558 Programming Languages
CS558 Programming Languages Fall 2016 Lecture 4a Andrew Tolmach Portland State University 1994-2016 Pragmatics of Large Values Real machines are very efficient at handling word-size chunks of data (e.g.
More informationRequest for Comments: 913 September 1984
Network Working Group Request for Comments: 913 Mark K. Lottor MIT September 1984 STATUS OF THIS MEMO This RFC suggests a proposed protocol for the ARPA-Internet community, and requests discussion and
More informationTopic 9: Type Checking
Recommended Exercises and Readings Topic 9: Type Checking From Haskell: The craft of functional programming (3 rd Ed.) Exercises: 13.17, 13.18, 13.19, 13.20, 13.21, 13.22 Readings: Chapter 13.5, 13.6 and
More informationTopic 9: Type Checking
Topic 9: Type Checking 1 Recommended Exercises and Readings From Haskell: The craft of functional programming (3 rd Ed.) Exercises: 13.17, 13.18, 13.19, 13.20, 13.21, 13.22 Readings: Chapter 13.5, 13.6
More informationCSC 467 Lecture 3: Regular Expressions
CSC 467 Lecture 3: Regular Expressions Recall How we build a lexer by hand o Use fgetc/mmap to read input o Use a big switch to match patterns Homework exercise static TokenKind identifier( TokenKind token
More informationCS101 Lecture 04: Binary Arithmetic
CS101 Lecture 04: Binary Arithmetic Binary Number Addition Two s complement encoding Briefly: real number representation Aaron Stevens (azs@bu.edu) 25 January 2013 What You ll Learn Today Counting in binary
More informationInteractive MATLAB use. Often, many steps are needed. Automated data processing is common in Earth science! only good if problem is simple
Chapter 2 Interactive MATLAB use only good if problem is simple Often, many steps are needed We also want to be able to automate repeated tasks Automated data processing is common in Earth science! Automated
More informationPrinceton University. Computer Science 217: Introduction to Programming Systems. Data Types in C
Princeton University Computer Science 217: Introduction to Programming Systems Data Types in C 1 Goals of C Designers wanted C to: Support system programming Be low-level Be easy for people to handle But
More informationCorresponding Parts of Congruent Triangles are Congruent
CPCTC Corresponding Parts of Congruent Triangles are Congruent.2 Learning Goals In this lesson, you will: Identify corresponding parts of congruent triangles. Use corresponding parts of congruent triangles
More informationPython Working with files. May 4, 2017
Python Working with files May 4, 2017 So far, everything we have done in Python was using in-memory operations. After closing the Python interpreter or after the script was done, all our input and output
More informationCS 61B Discussion 5: Inheritance II Fall 2014
CS 61B Discussion 5: Inheritance II Fall 2014 1 WeirdList Below is a partial solution to the WeirdList problem from homework 3 showing only the most important lines. Part A. Complete the implementation
More informationPython Input, output and variables. Lecture 23 COMPSCI111/111G SS 2018
Python Input, output and variables Lecture 23 COMPSCI111/111G SS 2018 1 Today s lecture What is Python? Displaying text on screen using print() Variables Numbers and basic arithmetic Getting input from
More informationCopyright 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley
Slide 7-1 Copyright 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Type Conversation / Casting Name Constant - const, #define X When You Mix Apples and Oranges: Type Conversion Operations
More informationPython Input, output and variables
Today s lecture Python Input, output and variables Lecture 22 COMPSCI111/111G SS 2016! What is Python?! Displaying text on screen using print()! Variables! Numbers and basic arithmetic! Getting input from
More informationCOMP 122/L Lecture 1. Kyle Dewey
COMP 122/L Lecture 1 Kyle Dewey About Me I research automated testing techniques and their intersection with CS education This is my first semester at CSUN Third time teaching this content About this Class
More informationCS 61C: Great Ideas in Computer Architecture C Pointers. Instructors: Vladimir Stojanovic & Nicholas Weaver
CS 61C: Great Ideas in Computer Architecture C Pointers Instructors: Vladimir Stojanovic & Nicholas Weaver http://inst.eecs.berkeley.edu/~cs61c/sp16 1 Agenda Pointers Arrays in C 2 Address vs. Value Consider
More informationChapter 5: Character and Paragraph Formatting in MS Word
Chapter 5: Character and Paragraph Formatting in MS Word 5.0 Learning Objectives At the end of this unit, you should be able to: 1. Perform character formatting 2. Change font size and color. 3. Paragraph
More informationPython Input, output and variables. Lecture 22 COMPSCI111/111G SS 2016
Python Input, output and variables Lecture 22 COMPSCI111/111G SS 2016 Today s lecture u What is Python? u Displaying text on screen using print() u Variables u Numbers and basic arithmetic u Getting input
More informationb. Suppose you enter input from the console, when you run the program. What is the output?
Part I. Show the printout of the following code: (write the printout next to each println statement if the println statement is executed in the program). a. Show the output of the following code: public
More informationCS102: Variables and Expressions
CS102: Variables and Expressions The topic of variables is one of the most important in C or any other high-level programming language. We will start with a simple example: int x; printf("the value of
More informationcs3157: another C lecture (mon-21-feb-2005) C pre-processor (3).
cs3157: another C lecture (mon-21-feb-2005) C pre-processor (1). today: C pre-processor command-line arguments more on data types and operators: booleans in C logical and bitwise operators type conversion
More informationA Step by Step Guide to Postcard Marketing Success
A Step by Step Guide to Postcard Marketing Success Table of Contents Why VerticalResponse?...3 Why Postcards?...4 So why use postcards in this modern era?...4 Quickstart Guide...6 Step 1: Setup Your Account...8
More informationCPSC 217 Assignment 3
CPSC 217 Assignment 3 Due: Monday November 26, 2018 at 12:00 noon Weight: 7% Sample Solution Length: Approximately 120 lines, including blank lines, lots of comments and the provided code Individual Work:
More informationData Types. Data Types. Integer Types. Signed Integers
Data Types Data Types Dr. TGI Fernando 1 2 The fundamental building blocks of any programming language. What is a data type? A data type is a set of values and a set of operations define on these values.
More informationCS61C Machine Structures. Lecture 4 C Pointers and Arrays. 1/25/2006 John Wawrzynek. www-inst.eecs.berkeley.edu/~cs61c/
CS61C Machine Structures Lecture 4 C Pointers and Arrays 1/25/2006 John Wawrzynek (www.cs.berkeley.edu/~johnw) www-inst.eecs.berkeley.edu/~cs61c/ CS 61C L04 C Pointers (1) Common C Error There is a difference
More informationCS3157: Advanced Programming. Outline
CS3157: Advanced Programming Lecture #8 Feb 27 Shlomo Hershkop shlomo@cs.columbia.edu 1 Outline More c Preprocessor Bitwise operations Character handling Math/random Review for midterm Reading: k&r ch
More information2. Numbers In, Numbers Out
REGZ9280: Global Education Short Course - Engineering 2. Numbers In, Numbers Out Reading: Moffat, Chapter 2. REGZ9280 14s2 2. Numbers In, Numbers Out 1 The Art of Programming Think about the problem Write
More informationChapter 11 Customizing I/O
Chapter 11 Customizing I/O Hartmut Kaiser hkaiser@cct.lsu.edu http://www.cct.lsu.edu/~hkaiser/fall_2010/csc1253.html Slides adapted from: Bjarne Stroustrup, Programming Principles and Practice using C++
More informationlast time in cs recitations. computer commands. today s topics.
last time in cs1007... recitations. course objectives policies academic integrity resources WEB PAGE: http://www.columbia.edu/ cs1007 NOTE CHANGES IN ASSESSMENT 5 EXTRA CREDIT POINTS ADDED sign up for
More information6.S096 Lecture 2 Subtleties of C
6.S096 Lecture 2 Subtleties of C Data structures and Floating-point arithmetic Andre Kessler January 10, 2014 Andre Kessler 6.S096 Lecture 2 Subtleties of C January 10, 2014 1 / 17 Outline 1 Memory Model
More informationThe C++ Language. Arizona State University 1
The C++ Language CSE100 Principles of Programming with C++ (based off Chapter 2 slides by Pearson) Ryan Dougherty Arizona State University http://www.public.asu.edu/~redoughe/ Arizona State University
More informationInstalling and Using Dev-C++
Installing and Using Dev-C++ 1. Installing Dev-C++ Orwell Dev-C++ is a professional C++ IDE, but not as big and complex as Visual Studio. It runs only on Windows; both Windows 7 and Windows 8 are supported.
More informationExtended Introduction to Computer Science CS1001.py. Lecture 5 Part A: Integer Representation (in Binary and other bases)
Extended Introduction to Computer Science CS1001.py Lecture 5 Part A: Integer Representation (in Binary and other bases) Instructors: Daniel Deutch, Amir Rubinstein Teaching Assistants: Michal Kleinbort,
More informationIntro to C: Pointers and Arrays
Lecture 4 Computer Science 61C Spring 2017 January 25th, 2017 Intro to C: Pointers and Arrays 1 Administrivia Teaching Assistants: Let s try that again. Lectures are recorded. Waitlist/Concurrent Enrollment
More informationCS 4410, Fall 2017 Project 1: My First Shell Assigned: August 27, 2017 Due: Monday, September 11:59PM
CS 4410, Fall 2017 Project 1: My First Shell Assigned: August 27, 2017 Due: Monday, September 11th @ 11:59PM Introduction The purpose of this assignment is to become more familiar with the concepts of
More informationCIS 110: Introduction to Computer Programming
CIS 110: Introduction to Computer Programming Lecture 3 Express Yourself ( 2.1) 9/16/2011 CIS 110 (11fa) - University of Pennsylvania 1 Outline 1. Data representation and types 2. Expressions 9/16/2011
More informationCS 64 Week 0 Lecture 1. Kyle Dewey
CS 64 Week 0 Lecture 1 Kyle Dewey Overview Administrative stuff Class motivation Syllabus Working with different bases Bitwise operations Twos complement Administrative Stuff About Me 5th year Ph.D. candidate,
More informationComputer Science 21b (Spring Term, 2015) Structure and Interpretation of Computer Programs. Lexical addressing
Computer Science 21b (Spring Term, 2015) Structure and Interpretation of Computer Programs Lexical addressing The difference between a interpreter and a compiler is really two points on a spectrum of possible
More informationLecture #5: Higher-Order Functions. A Simple Recursion. Avoiding Recalculation. Redundant Calculation. Tail Recursion and Repetition
nnouncements: Lecture #5: Higher-Order Functions Make sure that you have registered electronically with our system (not just TeleBERS). ttend a discussion/lab in which you can fit; don t worry about Tele-
More informationUsing the Zoo Workstations
Using the Zoo Workstations Version 1.86: January 16, 2014 If you ve used Linux before, you can probably skip many of these instructions, but skim just in case. Please direct corrections and suggestions
More informationLexical Analysis. Lecture 3-4
Lexical Analysis Lecture 3-4 Notes by G. Necula, with additions by P. Hilfinger Prof. Hilfinger CS 164 Lecture 3-4 1 Administrivia I suggest you start looking at Python (see link on class home page). Please
More informationExpress Yourself. The Great Divide
CS 170 Java Programming 1 Numbers Working with Integers and Real Numbers Open Microsoft Word and create a new document Save the file as LastFirst_ic07.doc Replace LastFirst with your actual name Put your
More informationDiscussion 1H Notes (Week 2, 4/8) TA: Brian Choi Section Webpage:
Discussion 1H Notes (Week 2, 4/8) TA: Brian Choi (schoi@cs.ucla.edu) Section Webpage: http://www.cs.ucla.edu/~schoi/cs31 Variables You have to instruct your computer every little thing it needs to do even
More informationITEC 1011 Introduction to Information Technologies
Number Systems Common Number Systems System Base Symbols Used by humans? Used in computers? Decimal 10 0, 1, 9 Yes No Binary 2 0, 1 No Yes Octal 8 0, 1, 7 No No Hexadecimal 16 0, 1, 9, A, B, F No No Quantities/Counting
More informationFull file at
Java Programming: From Problem Analysis to Program Design, 3 rd Edition 2-1 Chapter 2 Basic Elements of Java At a Glance Instructor s Manual Table of Contents Overview Objectives s Quick Quizzes Class
More informationChapter 3 Objects, Types, and Values
Chapter 3 Objects, Types, and Values Hartmut Kaiser hkaiser@cct.lsu.edu http://www.cct.lsu.edu/~hkaiser/fall_2010/csc1253.html Slides adapted from: Bjarne Stroustrup, Programming Principles and Practice
More informationCS 220: Introduction to Parallel Computing. Input/Output. Lecture 7
CS 220: Introduction to Parallel Computing Input/Output Lecture 7 Input/Output Most useful programs will provide some type of input or output Thus far, we ve prompted the user to enter their input directly
More informationCSE 413 Languages & Implementation. Hal Perkins Winter 2019 Structs, Implementing Languages (credits: Dan Grossman, CSE 341)
CSE 413 Languages & Implementation Hal Perkins Winter 2019 Structs, Implementing Languages (credits: Dan Grossman, CSE 341) 1 Goals Representing programs as data Racket structs as a better way to represent
More information1 ICS 161: Design and Analysis of Algorithms Lecture notes for January 23, Bucket Sorting
1 ICS 161: Design and Analysis of Algorithms Lecture notes for January 23, 1996 2 Bucket Sorting We ve seen various algorithms for sorting in O(n log n) time and a lower bound showing that O(n log n) is
More informationCOSC 2P91. Introduction Part Deux. Week 1b. Brock University. Brock University (Week 1b) Introduction Part Deux 1 / 14
COSC 2P91 Introduction Part Deux Week 1b Brock University Brock University (Week 1b) Introduction Part Deux 1 / 14 Source Files Like most other compiled languages, we ll be dealing with a few different
More informationUsing Microsoft Excel
About Excel Using Microsoft Excel What is a Spreadsheet? Microsoft Excel is a program that s used for creating spreadsheets. So what is a spreadsheet? Before personal computers were common, spreadsheet
More informationNumerical Computing in C and C++ Jamie Griffin. Semester A 2017 Lecture 2
Numerical Computing in C and C++ Jamie Griffin Semester A 2017 Lecture 2 Visual Studio in QM PC rooms Microsoft Visual Studio Community 2015. Bancroft Building 1.15a; Queen s W207, EB7; Engineering W128.D.
More informationChapter 11 Customizing I/O
Chapter 11 Customizing I/O Bjarne Stroustrup www.stroustrup.com/programming Overview Input and output Numeric output Integer Floating point File modes Binary I/O Positioning String streams Line-oriented
More informationInput/Output Streams: Customizing
DM560 Introduction to Programming in C++ Input/Output Streams: Customizing Marco Chiarandini Department of Mathematics & Computer Science University of Southern Denmark [Based on slides by Bjarne Stroustrup]
More informationUsing Microsoft Excel
Using Microsoft Excel Excel contains numerous tools that are intended to meet a wide range of requirements. Some of the more specialised tools are useful to only certain types of people while others have
More informationObjectives for this class meeting. 1. Conduct review of core concepts concerning contracts and pre/post conditions
CSE1720 Click to edit Master Week text 01, styles Lecture 02 Second level Third level Fourth level Fifth level Winter 2015! Thursday, Jan 8, 2015 1 Objectives for this class meeting 1. Conduct review of
More information1.7 Limit of a Function
1.7 Limit of a Function We will discuss the following in this section: 1. Limit Notation 2. Finding a it numerically 3. Right and Left Hand Limits 4. Infinite Limits Consider the following graph Notation:
More informationToday in CS161. Week #3. Learn about. Writing our First Program. See example demo programs. Data types (char, int, float) Input and Output (cin, cout)
Today in CS161 Week #3 Learn about Data types (char, int, float) Input and Output (cin, cout) Writing our First Program Write the Inches to MM Program See example demo programs CS161 Week #3 1 Data Types
More informationChapter 11 Customizing I/O
Chapter 11 Customizing I/O Bjarne Stroustrup www.stroustup.com/programming Overview Input and output Numeric output Integer Floating point File modes Binary I/O Positioning String streams Line-oriented
More information3.1. Chapter 3: Displaying a Prompt. Expressions and Interactivity
Chapter 3: Expressions and Interactivity 3.1 The cin Object Copyright 2009 Pearson Education, Inc. Copyright 2009 Publishing Pearson as Pearson Education, Addison-Wesley Inc. Publishing as Pearson Addison-Wesley
More informationStructure of Programming Languages Lecture 3
Structure of Programming Languages Lecture 3 CSCI 6636 4536 Spring 2017 CSCI 6636 4536 Lecture 3... 1/25 Spring 2017 1 / 25 Outline 1 Finite Languages Deterministic Finite State Machines Lexical Analysis
More informationCompiling C++ Programs Flow Control in C++ CS 16: Solving Problems with Computers I Lecture #3
Compiling C++ Programs Flow Control in C++ CS 16: Solving Problems with Computers I Lecture #3 Ziad Matni Dept. of Computer Science, UCSB Compiling Programs in C++ Input and Output Streams Simple Flow
More informationLECTURE 7. Lex and Intro to Parsing
LECTURE 7 Lex and Intro to Parsing LEX Last lecture, we learned a little bit about how we can take our regular expressions (which specify our valid tokens) and create real programs that can recognize them.
More information