.
Variable
A variable is a quantity that values is change any time when program execution. It is a memory location used to store a data value. A variable name should be choose carefully by programmer so that it is used in entire program.
Example : Int salary;
flout P, T, R;
char x;
String Name [20]
variable declaration
Variable is declaration as following syntax.
<Datatype> <variable_name>;
Example : Int x, y, sum =0;
float p, t, r, si=0;
double salary;
Rules for variable declaration
- A variable should not used keywords.
- Variable must begin with latter and underscore(-).
- Wide space is not allowed.
- Max length is 8 character only.
- Example :
|
|
|
|
|
|
|
|
|
|
Operators
An operator is a symbol that perform certain mathematical and logical operation on operator. It is define as an action upon the two possible values. This type of operation is strictly defined for any set of date.
Example : A + B where A & B are operands '+' is operator.
According to utilization and action operator are classified as :
- Arithmetic Operator
- Relational Operator
- Logical Operator
- Assignment Operator
- Increment / Decrement Operator
- Conditional Operator
- Bitwise Operator
- Special Operator
1. Arithmetic Operator
Arithmetic Operators are the operators which are used to perform mathematical calculations like addition (+), subtraction (-), multiplication (*), division (/) and modulus(%). It performs all the operations on numerical values (constants and variables).
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2. Relational Operator
Relational Operator are specifically used to compare two quantities or values in a program. It checks the relationship between two operands.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3. Logical Operator
An operator are used to compare and evaluate logical expressing. Then operator produce result either true (1) or false (0) form.
|
|
|
|
|
|
|
|
|
|
|
|
4. Assessment Operator
An assignment operator is mainly responsible for assigning a value to a variable in a program. It is used to assign the result of an expression to a variable.
shorthand assignment operator as
|
|
|
|
|
|
|
|
|
|
|
|
5. Increment / Decrement Operator
An operator which is used in increment / decrement value of an operands by one. It is also called unary operator because it takes only one operand for manipulation.
|
|
|
|
|
|
6. Conditional Operator
An operator which takes pair of operator ("?") to evaluate an expression. It is also called Ternary operator because its takes three operands for manipulation.
Syntax:
Expression ? Result 1 : Result 2
Example
If a = 5, b = 6
a>b? 10:20
Note : if condition is true result is first else result is second.
Hence, Result is 20.
Comments
Post a Comment