Guidelines

Guidelines - memory will be allocated to a particular 3:...

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

View Full Document Right Arrow Icon
Comments if(isdigit) /* error */ /* * Program to sort integer values */
Background image of page 1

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

View Full DocumentRight Arrow Icon
Comments and Identifiers Make every comment count. Don't over-comment. Make sure comments and code agree.
Background image of page 2
3: Line Structure, Identifiers Two lines my\ id are joined during compiler translation into myid An identifier is a sequence of letters,
Background image of page 3

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

View Full DocumentRight Arrow Icon
The documentation of programs, which are available to clients , should make it clear whether you are using identifiers whose length exceeds 6 characters. Never use identifiers that have more than 31 characters. Identifiers
Background image of page 4
Identifiers Use a consistent style throughout your code. Variables should have meaningful names when appropriate . You are encouraged to mix case to make your identifiers more readable:
Background image of page 5

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

View Full DocumentRight Arrow Icon
3: Primitive Data Types C provides several primitive data types: char , int , float and double . No built-in Boolean type; instead use int : the value 0 stands for false, any non-zero value stands for true No guarantee that a specific amount of
Background image of page 6
Background image of page 7

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

View Full DocumentRight Arrow Icon
Background image of page 8
Background image of page 9

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

View Full DocumentRight Arrow Icon
Background image of page 10
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: memory will be allocated to a particular 3: Memory and Range of Values • Computer memory consists of words ; each word consists of a number of bytes , a byte consists of a number of bits (usually 8 bits). • Signed integers use the leftmost bit (sign bit), to represent the sign. The largest unsigned 16-bit integer: 216 - 1 The largest signed 16-bit integer: 215 - 3: Integer Types • plain, signed and unsigned • short unsigned int • signed long • int • size ( short ) <= size ( int ) <= size ( long ) • To support portability, use only integers in the ranges specified in limits.h For example, you can always use plain integers in the range from -32,767 to 32,767 Any other assumptions, such as that the size of an int is 4 bytes, must not be made. Ranges • In order to check whether the sum of two integers i and overflows , • do not use • i + j > INT_MAX • Instead, use Overflow...
View Full Document

This note was uploaded on 02/18/2012 for the course CS 240 taught by Professor Rego during the Fall '08 term at Purdue.

Page1 / 10

Guidelines - memory will be allocated to a particular 3:...

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

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