Learn to Program with C_ Learn to Program using the Popular C Programming Language ( PDFDrive )
You also want an ePaper? Increase the reach of your titles
YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.
■ Contents
1.7 Write Output with printf ........................................................................................ 14
1.7.1 The Newline Character, \n (backslash n) .................................................................................... 15
1.7.2 Escape Sequences ...................................................................................................................... 16
1.7.3 Print the Value of a Variable ......................................................................................................... 16
1.8 Comments ................................................................................................................ 17
1.9 Programming with Variables .................................................................................... 18
■Chapter ■ 2: C – The Basics 23
2.1 Introduction .............................................................................................................. 23
2.2 The C Alphabet ......................................................................................................... 24
2.3 C Tokens ................................................................................................................... 24
2.3.1 Spacing Within a Program ........................................................................................................... 25
2.3.2 Reserved Words ........................................................................................................................... 27
2.3.3 Identifiers.................................................................................................................................... 27
2.3.4 Some Naming Conventions.......................................................................................................... 28
2.4 Basic Data Types ...................................................................................................... 28
2.5 Integer Numbers - int ............................................................................................. 29
2.5.1 Declaring Variables ...................................................................................................................... 29
2.5.2 Integer Expressions ..................................................................................................................... 29
2.5.3 Precedence of Operators ............................................................................................................. 30
2.5.4 Print an Integer Using a “Field Width” ......................................................................................... 31
2.6 Floating-Point Numbers – float and double ........................................................ 33
2.6.1 Print double and float Variables ................................................................................................ 34
2.6.2 Assignment Between double and float ..................................................................................... 36
2.6.3 Floating-Point Expressions .......................................................................................................... 36
2.6.4 Expressions with Integer and Floating-Point Values.................................................................... 37
2.6.5 Assigning double/float to int .................................................................................................. 38
2.7 Strings ...................................................................................................................... 38
2.8 The Assignment Statement ...................................................................................... 41
2.9 printf ..................................................................................................................... 42
viii
www.it-ebooks.info