W07-CharDataType

W07-CharDataType - Character Data Type 10/3/05 1 A New Data...

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

View Full Document Right Arrow Icon
10/3/05 1 Character Data Type 10/3/05 2 A New Data Type - char • Just when you were starting understand the difference between int, float, and double! char b = 'z'; • Holds one character (i.e a-z, A-Z, 0-9, etc). • Uses one byte of storage • A small integer type (values 0 to 255) 10/3/05 3 The ASCII Code A merican S tandard C ode for I nformation I nterchange. • Each character is assigned a code (number). • These codes are the numbers in a char variable. • ASCII codes go from 0 to 127 • 0-31 are control codes, rest are printable characters.
Background image of page 1

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

View Full DocumentRight Arrow Icon
4 Char constants and variables char c1, c2; c1 = 'A'; /* 65 assigned to c1 */ c2 = 65; /* same thing */ printf("%c %c %c %c", c1, c2, 65, 'A'); the output is: A A A A 10/3/05 5 int main( void ) { int row, col; printf(" "); for (col=2; col < 16; ++col) /* print col headings */ printf("%4d", col*16); printf("\n"); for (row=0; row < 16; ++row) { printf("%02d", row); /* print row number */ for (col=2; col < 16; ++col) { printf("%4c", row + 16*col);
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 4

W07-CharDataType - Character Data Type 10/3/05 1 A New Data...

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

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