Beruflich Dokumente
Kultur Dokumente
Data types
What is data type ?
1. Short. 2. Long.
Character : 1 byte Signed char: (-128 to 127) Unsigned char: (0 to 255) Seer Akademi Pvt. Ltd., 2012 Seer Akademi Confidential
Operators:
Binary operators
Unary operators
Ternary operators
Binary operators: Arithmetic operators Relational operators Logical operators Assignment operators Seer Akademi Pvt. Ltd., 2012 Seer Akademi Confidential
Arithmetic operators:
+, - , * , / , %.
(BODMAS)
Assignment operators: =, +=, -=, *=, /=, %=. (modify the value of variables) Unary operators: ++ operators. -- operators.
Bitwise operators
Syntax: operand1 ? Operand2 : operand3; Seer Akademi Pvt. Ltd., 2012 Seer Akademi Confidential
IF Condition: Syntax: if(condition) { statements; } else { statements; } if(condition) { statements; } if(condition) statement; Seer Akademi Pvt. Ltd., 2012 Seer Akademi Confidential
LOOPS
Nested while:
Syntax:
For loop :
For(exp1; ;exp3) { }
For(;;exp3) {
} For(; exp2;) { } For(; ;) { }
What is advantage?
Types : Single dimension array Multi dimension array Single dimension array:
String :
Syntax :
Syntax: data type array_name [row size][column size] Note : row size and column size must be constants but should not be variables.
SWITCH
Syntax:
Switch (exp) { Case constant-1 : statements : statements Case constant _n: statements : statements Seer Akademi Pvt. Ltd., 2012 Seer Akademi Confidential
Rules : Duplicate cases are not allowed. Expression must be of integer type. Default can be written any where in the switch. Case must be followed by a constant.
POINTER
Pointer is a inherits the properties of the data type. A variable declared using pointer data type is called pointer Pointer variable holds an address of memory location. variable.
Syntax:
Data type *variable_name; Int *x; Float *y; Char *z; Double *d;
2 bytes
For any data type the size of pointer is 2 bytes, b/c it holding address not value.
FUNCTIONS
Function is divided into two parts: Function declaration (or) Function prototype. Function definition. Compiler recognize the function with prototype.
Function prototype:
Syntax: <return_type> function_name ([<parameter_type>]);
Function declaration:
Syntax:
function_name (parameters);
Function definition
Syntax: <return_type> function_name ([<parameter_type>])