Introduction to Programming Lecture 22 Review
Bit wise Manipulation and Assignment Operator
a = a + 1 ; a += 1 ;
Bit Manipulation Operators &= Bitwise AND Assignment Operator |= Bitwise OR Assignment Operator ^= Bitwise Exclusive OR Assignment Operator
Assignment Operator a &= b ; Same as a = a & b ;
Assignment Operator a |= b ; Same as a = a | b ;
Assignment Operator a ^= b ; Same as a = a ^ b ;
Design Recipes PAY ATTENTION TO DETAIL Analyze a problem statement, typically expressed as a word problem Express its essence, abstractly and with examples Formulate statements and comments in a precise language Evaluate and revise the activities in the light of checks and tests. PAY ATTENTION TO DETAIL
Variables
Symbolic Names x i BasicPay HouseRent
Data types Whole numbers: Real Numbers (with decimal points) int, short, long, unsigned Real Numbers (with decimal points) float, double Character data char
int = 4 bytes char = 1 byte
ASCII Table
Arrays Collection of same data types
Arithmetic Operators Plus + Minus - Multiply * Divide / Modulus %
Modulus Operator a % b ; 7 % 2 = 1 ; 100 % 20 = 0 ;
Compound Arithmetic Operators += -= *= /= %=
Compound Arithmetic Operators a = a + b ; a += b ;
Logical Operators AND && OR ||
a < b ; a <= b ; a == b ; a >= b ; a > b ; Comparison Operators a < b ; a <= b ; a == b ; a >= b ; a > b ;
a = b;
if ( a = b ) //Wrong //Logical Error
a > b ; a >= b ;
Bit wise Operators Bit wise AND & (Binary) Bit wise OR | (Binary) Bit wise Exclusive OR ^ (Binary) NOT ~ (unary)
Sequential Construct Decision Construct Loop Construct
If-statement if ( condition ) { statement ( s ) ; }
If-else if ( condition ) { statement ( s ) ; } else
if ( a > b && c < d )
Nested if statements
if ( condition ) { statement ( s ) ; }
While Loops while ( a > b ) { statement ( s ) ; }
While Loops While loop executes zero or more times
Do - while do { statement ( s ) ; } while ( condition ) ;
Do-while loop executes one or more times
For Loops for ( i = 0 ; i < 10 ; i ++ ; ) { statement ( s ) ; }
i = i + 1 ; i += 1 ; i ++ ;
Switch Statement
break ; continue ;
Functions
Call by value Call by reference
Arrays
Arrays int a [ 10 ] ; a [ 0 ] ; : a [ 9 ] ;
Pointers
Memory address of a variable is stored inside a pointer Pointers Memory address of a variable is stored inside a pointer
Files and their Input / Output systems