# week5 - Unix C GNU HTML Perl Python The C Programming...

This preview shows pages 1–12. Sign up to view the full content.

Unix C + GNU HTML Perl Python COMP 206 - Joseph Vybihal 2007 1 The C Programming Language Comp-206 : Introduction to Software Systems Week 5 Joseph Vybihal Computer Science McGill University

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

View Full Document
Unix C + GNU HTML Perl Python COMP 206 - Joseph Vybihal 2007 2 Announcements
Unix C + GNU HTML Perl Python COMP 206 - Joseph Vybihal 2007 3 Part 1 Basic C Statements and Expressions

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

View Full Document
Unix C + GNU HTML Perl Python COMP 206 - Joseph Vybihal 2007 Arithmetic Operations C provides the basic arithmetic operations : + - * / The modulus (%) operator is also provided. For efficiency purposes, it also provides an increment and decrement operators : ++ -- += -= *= /= %= etc. Note that / operation for float and integer is very different. Unless both operands are float, the division will be integer based.
Unix C + GNU HTML Perl Python COMP 206 - Joseph Vybihal 2007 5 No BOOLEAN Type Uses INT: Integer 0 = false Any other number = true Math and boolean? (is it an even number?) int x = 10; if (x) printf (“TRUE!”);

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

View Full Document
Unix C + GNU HTML Perl Python COMP 206 - Joseph Vybihal 2007 Comparison Operators C provides the following comparison operators: == : equality != : not equal < : smaller than > : greater than <= : smaller or equal than >= : greater or equal than Please note that testing for equality is done using the == operator, which is not the same as = if ( a == 1 ) { // Good test if ( a = 1 ) { // Assigns the value of 1 to a // and will always test as true int x = 5 < 10;
Unix C + GNU HTML Perl Python COMP 206 - Joseph Vybihal 2007 Logical Operators C provides the following logical operator: || : OR ! : NOT These can be used with the comparison operators: if ( (a == 5) || (a == 6) ) // a = 5 or 6 if ( !(a == 5) ) // a is not 5 if ( a != 5 ) // a is not 5 int x = (a == 5) || (a == 6);

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

View Full Document
Unix C + GNU HTML Perl Python COMP 206 - Joseph Vybihal 2007 8 Bit operators | Logical OR >> Shift right << Shift left ~ one’s complement Examples. ..
Unix C + GNU HTML Perl Python COMP 206 - Joseph Vybihal 2007 9 Characters Every character is stored as a number, including spaces, digits, and punctuation Corresponding upper and lower case letters are separate characters H i , H e a t h e r . 72 105 44 32 72 101 97 116 104 101 114 46

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

View Full Document
Unix C + GNU HTML Perl Python COMP 206 - Joseph Vybihal 2007 10 Characters in C Syntax : SCOPE MODIFIER char VARNAME = ‘C’; A single character in single quotes 67 VARNAME Stored as an integer number (a code in integer) 8 bits start address Math with characters. .. encryption
Unix C + GNU HTML Perl Python COMP 206 - Joseph Vybihal 2007 11 Strings in C Syntax : SCOPE MODIFIER char* VARNAME = “characters”; Many characters in double quotes ‘c’ ‘h’ ‘a’ ‘r’ ‘a’ ‘c’ ‘t’ ‘e’ ‘r’ ‘s’ 8 bits start address ‘\0’ The NULL character Printf w/o NULL?

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

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### Page1 / 44

week5 - Unix C GNU HTML Perl Python The C Programming...

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

View Full Document
Ask a homework question - tutors are online