{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

lecture 17 week5

# lecture 17 week5 - Unix C GNU HTML Perl Python Teacher's...

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

Unix C + GNU HTML Perl Python COMP 206 - Joseph Vybihal 1 Teacher's Notes

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 2 The C Programming Language Comp-206 : Introduction to Software Systems Week 5 Joseph Vybihal Computer Science McGill University
Unix C + GNU HTML Perl Python COMP 206 - Joseph Vybihal 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 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 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 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 Logical Operators C provides the following logical operator: && : AND || : OR ! : NOT These can be used with the comparison operators: if ( (a == 5) || (a == 6) ) // a = 5 or 6 if ( (a == 3) && (b == 4) ) // a = 3 and b = 4 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 8 Bit operators & Logical AND | Logical OR >> Shift right << Shift left ~ one’s complement Examples...
Unix C + GNU HTML Perl Python COMP 206 - Joseph Vybihal 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 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 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
Unix C + GNU HTML Perl Python COMP 206 - Joseph Vybihal 12 Strange Properties of Strings in C What happens if the string does not have the \0 at the end?
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### Page1 / 44

lecture 17 week5 - Unix C GNU HTML Perl Python Teacher's...

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

View Full Document
Ask a homework question - tutors are online