Skip to main content

Introduce constants, variables, operators and expressions and apply them.

 .

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 :

 Valid

 Invalid

 sum

switch/goto/while 

 emp_name/emp_salary

 emp salary

 emp_age12

12emp_age 

 _Age

Age_ 


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 :
  1. Arithmetic Operator
  2. Relational Operator
  3. Logical Operator
  4. Assignment Operator
  5. Increment / Decrement Operator
  6. Conditional Operator
  7. Bitwise Operator
  8. 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).

 Operator

Meaning 

Example 

Add 

A + B 

 -

Sub 

A - B 

 *

Mul 

A * B 

 /

Div 

A/B 

 %

Modulo 

A%B 



2. Relational Operator 

Relational Operator are specifically used to compare two quantities or values in a program. It checks the relationship between two operands.

 Operator

Meaning 

Example 

 >

Greater than 

A>B 

 >=

Greater equal to 

A>=B 

 <

Less than 

A<B 

 <=

Less equal to 

A<=B 

 = =

equal to 

A= =B 

 !=

No equal to 

A!=B 



3. Logical Operator

An operator are used to compare and evaluate logical expressing. Then operator produce result either true (1) or false (0) form.

 Operator

Meaning 

Example 

 &&

Logical AND 

(a>b && a>c) 

 ||

Logical OR 

(a>b || a>c) 

 !=

Logical NOT

a!=b 


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

Expression 

Shorthand 

 a = a+b

a+ = b 

 a = a-b

a- = b 

 a = a*B

a* = b 

 a = a/b

a/ = b  

 a = a%b

a% = b 


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.

 Operator

Meaning 

 a++

a = a + 1 

 a--

a = a - 1 


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

Popular posts from this blog

Introduction of Computer

.  A computer is an electronic device. It take input and store the data in memory and performing the function to produce accurate result in output device. It is used to type document, send email, play game, browse the web and entertainment.   Characteristics of computer  1 . High speed  Computer is very fast device. It is capable of performing calculation of very large amount of data. The computer has unit of speed in microsecond, nanosecond and even in picosecond. The computer is capable of performing millions of tasks per second. 2. Accuracy  The computer produces highly accurate and reliable result.  It does not make any kind of mistake in calculating. The calculation are 100% error free. The computers perform accurate 'n' number of times. 3. Storage capability A computer has much more storage capability. It can store large amount of data. It can store any type of data such as image, video, text document, audio and many more. 4. Diligence Diligence ...

Introduce Linux, UNIX and Linux distribution.

 . Linux Linux is an open source operating system. The term Linux is actually referred to mean a kernel of Unix like operating system developed by a Finish software architect Linus Torvald. The name Linux is derived from Linus' Unix. Linux was originated from the inspiration of a small Unix like operating system MINIX by A.S Tanenbum. Linux is a complete multiuser, multiprocessing, secure and stable operating system which is also considered as UNIX clone. However no code from the proprietary from AT and T is included in Unix. It has flavor of Unix but is not Unix. UNIX  UNIX is a layered operating system. The innermost layer is the hardware that provides the service for the OS. The operating system, referred to in UNIX as the kernel, interacts directly with the hardware and provides the services to the user program. These user programs don't need to know anything about the hardware. They just need to know how to interact with the kernel and it's up to the kernel to provide ...

Open System Interconnect (OSI) Reference Model

 . Open system interconnection (OSI) Model explains how packet travels through various layers to other devices on a network, even if the sender and destination have different types of network media. Layer 1(Physical layer):  Function  To activate, maintain, deactivate the physical connection.  To define voltage and data rates needed for transmission.  To convert the digital bits into electrical signals.  To decide weather the transmission the transmission is simplex, half or full duplex.  Physical layer doesn’t perform the detection and correction of errors. Layer 2 (Datalink layer):  Framing (stream of bits into manageable data units):  The datalink layer divides the stream of bits received from the network layer into frame manageable data units called frames.  Physical addressing (MAC Address):  Data link layer adds a header to header to the frame to define the sender and receiver of the frame. Flow Control (mechanism for overwhel...