0
Mixed Mode Operation and Automatic (Implicit) Conversion – When operands of different data types are used in an arithmetic expression, one of the operand data type will be converted to the type of other operand. This conversion is taking place automatically during program execution and is referred to automatic type conversion or implicit conversion.
            The order of conversion is as follows:
char → int → long int → float → double
                   (Low ranking)                                                      (High Ranking)
Ex:
int m = 15;
float x = 3.1, y;
y = m*x;
                              │   ↓
                              ↓    Its type float is high rank.
                         Its type int is converted to float.

The result obtained by mixing float and int in the above expression is float, which is assigned to y.

Cast or Explicit Conversion – Cast operation is used to overcome automatic conversion. The variable declared in specific data type can be converted into the required type as shown below:
                       
                                    (type) expression
                                                Or
                                    (type) (expression)


Ex:
                        int m = 5;
                        float y;
y = (float) m/2;

In the above expression, the int variable m is converted into float to get the result 2.5; otherwise the result will be 2.


Operator Precedence and Associativity – The compute scans an expression which contains the C operators from left to right and performs only one operation at a time. The expression will be scanned many times to produce the result.
The order in which various operations are performed is known as hierarchy of operations or operation precedence.
            Some of the operators of the same level of precedence are evaluated from left to right or right to left. This is referred to associativity.
Ex:
                        S = s + x;
Associativity for the operator (+) is from left to right

                        S+= x;
Associativity for the operator (+=) is from right to left

Note – The operators in higher level will be executed first. When operators have the same level, the one at the left side will be executed first.

Precedence order
Operator
Associativity
1
( )     [ ]     →
Left to right
2
++   --   - (unary)   !   ~   *   &   sizeof
Right to left
3
  *     /      %
Left to right
4
+    -
Left to right
5
<<       >>
Left to right
6
 <        <=       >       >=
Left to right
7
==        !=
Left to right
8
  & (bitwise AND)
Left to right
9
  ^ (bitwise XOR)
Left to right
10
  | (bitwise OR)
Left to right
11
 && (logical AND)
Left to right
12
 | | (logical OR)
Left to right
13
 ? : (conditional)
Right to right
14
 =       +=     - =      *=      /=      %=
          
(assignment operators)
Right to left
15
  ,   (comma Operator)
Left to right


Structure of a C Program – C language does not actually follow any specific method of writing a program. It is a case sensitive language. All the statements must be written in lower case letters (small letters). The structure of a C program is as follows:-

<Header file>
<Global declaration of variable>
main ( )
{
                                    <local declaration of variables>
                                    ---------------------------------
                                    <statements>
                                    --------------------------------
}
                        <sub-programs- function blocks>

Note –
(i)                 The header files or preprocessor directives give instructions to the complier to include complier option (#include), macro substitution (#define) to substitute a constant for an identifier and conditional (#ifdef) directives.

(ii)               The main statement block, function block and other blocks used in a C program are enclosed in braces { }.

(iii)             Variable declared outside main ( ) are called global variables and they can be used in the main program block and sub program block.

(iv)             Variables declared inside main ( ) are called local variables, and they are used only in block in which they are declared. Sub program/function can also have local variables.

(v)               Any C program has coding in the form of letters and symbols. Normally documentation to the program is made by adding remarks or comment lines enclosed in /* and */ whenever necessary.







Like it ? Share it.

Post a Comment

Comment Rules :
1. Do not post Adult/illegal Links.
2. Try to comment in only English Language.
3. Do not post other website's links which are useless.
4. Your Comment should be based on the Topic for other queries Kindly Visit our Contact Us Page.
5. Do not use Abusive Language.
6. Respect each other.
Thank You for following the rules. Please Comment....

 
Top