Latest Post
Showing posts with label Expression-Statement-Token. Show all posts
Showing posts with label Expression-Statement-Token. Show all posts

Operators And Its Classification

Written By Unknown on Tuesday, October 8, 2013 | 4:03 AM

Operators :
Operators are some symbol or word in C Program which give instruction to the compiler to do some mathematical or logical task.

EX :                            a+b

Here + is an operator.Data ,Variable and Expression where operator works on is called operand.Like a+b,here a and b is operand.
                           
                                   a              +              b
                                    |               |               |
                           Operand     Operator     Operand

There are different type of operator in C.Like :

                                  * Mathematical Operator
                                            -> Unary Mathematical Operator
                                            -> Binary Mathematical Operator
                                  * Assignment Operator
                                  * Logical Operator
                                  * Relational Operators
                                  * Conditional operators
                                  * Bitwise Operators
                                  * Special Operators

Mathematical Operators : Mathematical Operators are +, -,*,\ etc.
5 binary and 2 unary mathematical operators are available in C.

Binary Operators: It can work with two operand at a time.Binary Operators are :

                                  Addition :                   +
                                  Subtraction :               -
                                  Multiplication :            *
                                  Division :                    /
                                  Reminder/Modulus :   %

Unary operator : It can work with one operand at a time.They are :

                                  Inorement :                ++
                                  Decrement :               --
                                  Unary minus :             -

Assignment Operators : ( = ) is used as assignment operator in C.

Relational Operators : Relational Operators are used to compare two variable in C.Like

                                                                    a < b
There are 6 relational operators in C.They are listed below :
                                                Equal :                              ==
                                                Greater than :                    >
                                                Less than :                         <
                                                Greater than or equal :       >=
                                                Less than or equal :           <=
                                                Not equal :                       ! =

Logical operator : Logical Operators are listed below:
                                   Operator       -           Symbol             -      Example
                                   
                                      AND          -             &&                -      a>b && b>c
                                      OR             -              | |                   -      a>b | |  b>c
                                      NOT          -               !                   -           !a

Conditional Operator : Conditional operator can work with three operand at a time.
EX :                               c = ( a>b ) ? a : b

Constants and Symbolic Constants in C Program

Written By Unknown on Monday, October 7, 2013 | 3:32 PM

Constants :
Constants is a type of value of a program that we can not change after running the program.So the value of constants is unchangeable.

There are two type of Constants in C :

                                                                           Constants
                                                                                  |
                                          1.Literal Constants                      2.Symbolic Constants

1.Literal Constants :
                                           5x^2 + 9y + c = 11;

Here 5 and 9 is literal Constants because when we run the program we can't change the value of 9,5 and 11.

Symbolic Constants :
This type of Constants are declared through a defined name.After running the program these values remain unchangeable.

Ex    :                                  int i = 10;
                                            i = i+1;

There are many kind of symbolic Constants like integer constant,float and double constant,character constant,string constant

Token,Keywords and Identifiers

Token :
When we compile a program,compiler justify the program is correct or not.If there is no syntax error in our program then compiler take the whole program as some token.

Like a language contain a lot of words or symbol,C language also contain some token. Compiler turns those token into computer usable code.

Keywords :
Keywords are some reserved words that compiler can define and work with them.Like char is a keyword.According to ANSI C contain a total number of 32 keywords.

Keyword List :
1.auto                                 11.enum                           21.short
2.break                               12.extern                          22.signed
3.case                                 13.float                             23.sizeof
4.char                                 14.for                                24.static
5.const                                15.goto                             25.struct
6.continue                            16.if                                  26.switch
7.default                              17.int                                 27.typedef
8.do                                    18.long                              28.union
9.double                              19.register                         29.void
10.else                                20.return                            30.while

Identifiers : 
Identifiers are some name which is given to a variable,function or array in a program.

Ex :                              char ch
Here ch is an identifier.

Expression,Statement and Compound Statement

Expression :
Expression is such kind of a program that has its own numeric value as like int a or #define PL etc.Expression is evaluated by assignment ( = )

Variable = Expression

There are two types of expression :
                                        Expression
                                                |
                                  1.Simple Expression
                                  2.Complex Expression

Simple Expression : 
Simple Expressions are made by a single part like variable,constant etc.

                                  Simple Expression          ----          Description


  1.                 Name                                    ----           Variable
  2.                 20                                         ----            Literal Constant
  3.                 MINUTE_PER_HOUR        ----           Symbolic Constant   
Complex Expression :
When a simple expression contain any operator like +,-,% etc then it called complex expression.

Ex : 2+8, x=y+5, x=y=10 etc

Statement :
We know we can give instruction to do something to computer through program.Statement is that type of part of a program where an instruction is given by us to computer.Statement could be one or multiple lined.After each statement we must put semicolon( ; ) to complete that statement except #include and # define.

Ex:                                            a=5+10;
                                                  p=q;

We can use white space,space,tab in statement.Like 
                                                  a=5+10

We can write it like below:
                                                 a         =
                                               
                                                 5

                                                 +

                                                 10;

Compound Statements :
When more then one statement stay in between  two brace " {  } " is called compound statement or block.

Ex :

{
printf("COMPOUND");
printf("STATEMENTS");
printf("EXAMPLE");
}

CONFUSE??

CONFUSE??
 
Support : Creating Website | Johny Template | Mas Template
Copyright © 2011. Learn Programming - All Rights Reserved
Template Created by Creating Website Published by Mas Template
Proudly powered by Blogger| Distributed by Rocking Templates