Introduction to Programming Lecture 22 Review Bit wise
Introduction to Programming Lecture 22 Review
Bit wise Manipulation and Assignment Operator
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 Analyze a problem statement, typically expressed as a word problem n Express its essence, abstractly and with examples n Formulate statements and comments in a precise language n Evaluate and revise the activities in the light of checks and tests. n n PAY ATTENTION TO DETAIL
Variables
Symbolic Names x i Basic. Pay House. Rent
Data types n Whole numbers: – int, short, long, unsigned n Real Numbers (with decimal points) – float, double n 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 && ||
Comparison Operators a<b; a <= b ; a == b ; a >= b ; a>b;
if ( a = b ) //Wrong //Logical Error
Bit wise Operators Bit wise AND & Bit wise OR | Bit wise Exclusive OR ^ NOT ~ (Binary) (unary)
Sequential Construct n Decision Construct n Loop Construct n
If-statement if ( condition ) { statement ( s ) ; }
If-else if ( condition ) { statement ( s ) ; } else { statement ( s ) ; }
Nested if statements
if ( condition ) { statement ( s ) ; } if ( condition ) { statement ( s ) ; } 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 Do-while loop executes one or more times
For Loops for ( i = 0 ; i < 10 ; i ++ ; ) { statement ( s ) ; }
Switch Statement
break ; n continue ; n
Functions
Call by value n Call by reference n
Arrays
Arrays int a [ 10 ] ; a[0]; : a[9];
Pointers
Pointers Memory address of a variable is stored inside a pointer
Files and their Input / Output systems
- Slides: 45