Welcome to Scribd, the world's digital library. Read, publish, and share books and documents. See more
Download
Standard view
Full view
of .
Save to My Library
Look up keyword or section
Like this
1Activity

Table Of Contents

0 of .
Results for:
No results containing your search query
P. 1
thinkCScpp

thinkCScpp

Ratings: (0)|Views: 8 |Likes:
Published by Jiz Satar

More info:

Published by: Jiz Satar on Dec 03, 2010
Copyright:Attribution Non-commercial

Availability:

Read on Scribd mobile: iPhone, iPad and Android.
download as PDF, TXT or read online from Scribd
See more
See less

11/08/2011

pdf

text

original

 
How to think like a computer scientist
Allen B. DowneyC++ Version, First Edition
 
2
How to think like a computer scientist
C++ Version, First EditionCopyright (C) 1999 Allen B. DowneyThis book is an Open Source Textbook (OST). Permission is granted toreproduce, store or transmit the text of this book by any means, electrical,mechanical, or biological, in accordance with the terms of the GNU GeneralPublic License as published by the Free Software Foundation (version 2).This book is distributed in the hope that it will be useful, but WITHOUTANY WARRANTY; without even the implied warranty of MERCHANTABIL-ITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU GeneralPublic License for more details.The original form of this book is LaTeX source code. Compiling this LaTeXsource has the effect of generating a device-independent representation of atextbook, which can be converted to other formats and printed. All intermediaterepresentations (including DVI and Postscript), and all printed copies of thetextbook are also covered by the GNU General Public License.The LaTeX source for this book, and more information about the OpenSource Textbook project, is available from
http://www.cs.colby.edu/~downey/ost
or by writing to Allen B. Downey, 5850 Mayflower Hill, Waterville, ME 04901.The GNU General Public License is available from www.gnu.org or by writ-ing to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,MA 02111-1307, USA.This book was typeset by the author using LaTeX and dvips, which are bothfree, open-source programs.
 
Contents
1 The way of the program 1
1.1 What is a programming language? . . . . . . . . . . . . . . . . . 11.2 What is a program? . . . . . . . . . . . . . . . . . . . . . . . . . 31.3 What is debugging? . . . . . . . . . . . . . . . . . . . . . . . . . 41.3.1 Compile-time errors . . . . . . . . . . . . . . . . . . . . . 41.3.2 Run-time errors . . . . . . . . . . . . . . . . . . . . . . . . 41.3.3 Logic errors and semantics . . . . . . . . . . . . . . . . . 41.3.4 Experimental debugging . . . . . . . . . . . . . . . . . . . 51.4 Formal and natural languages . . . . . . . . . . . . . . . . . . . . 51.5 The rst program . . . . . . . . . . . . . . . . . . . . . . . . . . . 71.6 Glossary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
2 Variables and types 11
2.1 More output . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 112.2 Values . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 122.3 Variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 132.4 Assignment . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 132.5 Outputting variables . . . . . . . . . . . . . . . . . . . . . . . . . 142.6 Keywords . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 152.7 Operators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 162.8 Order of operations . . . . . . . . . . . . . . . . . . . . . . . . . . 172.9 Operators for characters . . . . . . . . . . . . . . . . . . . . . . . 172.10 Composition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 182.11 Glossary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
3 Function 21
3.1 Floating-point . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 213.2 Converting from
double
to
int
. . . . . . . . . . . . . . . . . . . 223.3 Math functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . 233.4 Composition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 243.5 Adding new functions . . . . . . . . . . . . . . . . . . . . . . . . 243.6 Denitions and uses . . . . . . . . . . . . . . . . . . . . . . . . . 263.7 Programs with multiple functions . . . . . . . . . . . . . . . . . . 273.8 Parameters and arguments . . . . . . . . . . . . . . . . . . . . . 27i

You're Reading a Free Preview

Download
/*********** DO NOT ALTER ANYTHING BELOW THIS LINE ! ************/ var s_code=s.t();if(s_code)document.write(s_code)//-->