sorcerer_see: (Default)
PS I synthesize here in my own words what K&R teach, re-write all their example programs, character by character, solve all the C exercises they hand out. I comment to what K&R teach cursively. I do not copy-paste anything from the book! In regards to the percentages listed: books often have prefaces with Roman numbers and often also lengthy Appendices. In my calculation I include all pages that I effectively study and synthesize.

TCPL 2Ed - Page 008 to 009 - 4.90% Completion

1.2 Variables and Arithmetic Expressions

k-r_prg002.c


k-r_prg002.out



In this example we find
  • comments
  • declarations
  • variables
  • arithmetic expressions
  • loops
  • formatted output

This:

/* print Fahrenheit-Celsius table
for fahr = 0, 20, ..., 300 */


is a comment. It explains to programmers what the program does. Characters between /* and */ are ignored by the compiler. These symbols are used to state information within the program without affecting it. Such comments can be placed anywhere in a program.

This:

int fahr, Celsius;
int lower, upper, step;


are variables being declared, meaning that they can now be used within the program. The syntax int indicates that the variables are meant to be of the type integer.

Other types of variables are:

  • float
floating point: fractional numbers. Typically 32bit (in 1989) , 6 digits and a magnitude of   to the power of -38 to 10 to the power of 38.                                                                           
  • char
a single byte character
  • short
a short integer
  • long
a long integer
  • double
double-precision floating point

Exact size depends on the machine.

Besides variables, also arrays, structures, unions, pointers to these and functions deal with all of these types. All of this will be explained later in the book, say K&R.

Profile

sorcerer_see: (Default)
sorcerer_see

October 2025

S M T W T F S
    12 34
56 7 8 9 10 11
12 1314 15 16 1718
19 2021 22 23 2425
2627 28293031 

Style Credit

Expand Cut Tags

No cut tags
Page generated Jan. 17th, 2026 08:48 am
Powered by Dreamwidth Studios