Fundamentals of C Language

 

“C” Tokens

Individual words and punctuation marks are characters. In a “C” program the smallest individual units are known as “C” tokens. It has 6types of token‟s
  1. Keywords
  2. Identifiers
  3. Constants
  4. Variables
  5. Data types
  6. Type def
Keywords
Keyword is an predefined word ,Which is an already defined by the C-Develphers
Ex:int ,float,char,if etc...
C-Language contains 32 Keywords

Constants
Constant is an identifier whose value can't be changed.
Ex:int x=10;
Here 10 is a Constant
x is a Variable
int is a Datatype
These constants are classified into 2 types
  1. Numerical Constants
  2. Character Constants
  • Numerical Constants:
  • Numerical Constants menans Numbers these are classified into 2 types
    1. Integer Constants
    2. Real Constants
    Integer Constants: Integer constants means + or -(minus) values
    Ex:int x=10;
         int y=-24;
    Real Constants Real constants means floating values
    Ex:float x=1.0;
  • Character Constants
  • Character constants menas Characters these are classified into 2 types
    1. Single character constants
    2. String character constants
    Single character Constants: If any character or symbol or number enclosed with single quotation
    Ex:char ch='a'
         char ch='@';
         char ch='4';
    String character Constants Group of character or symblos or numbers enclosed with double quotation
    Ex:char ch[20]="varshini";

Variable

Variable
   Variable is an identifier whose value can be changed or which holds the data
Ex:int x=12;
          x=20;
Variable Declaration Rules:
  1. Variable name must be start with alphabet or underscore or doller symbol
  2. Ex:int age=12;
         int _age=24;
         int $age=45;
  3. The max length of the variable name is upto 32 characcters
  4. If variable name contains morethan one word ,The second word onwords first letter should be uppercase letter
  5. Ex:int studentAge=12;
  6. No spaces are allowed at the middle of the variable declaration
  7. Ex:int student Age=24; (Invalid)
  8. If variable value contains constant value that variable name must be uppercase
  9. Ex: const float PI=3.14
           const int AGE=24;
  10. If constant variablename contains morethan one word ,It should be separated with underscore
  11. Ex:const int STUDENT_AGE=24;
  12. All keywords are lowercase letters
  13. We should not take keyword as a variable name
  14. Ex: int if=12 (invalid) Here if is a keyword
Variable Defination Types
  1. Initilization
  2. Declaration
  3. Assignment
  • Initilization:
  • It menas initilize the some value to the variable
    Ex:int x=12; here 12 is initilize to the x
  • Declaration
  • In the Declaration no value initilize to the variable
    Ex:int x;
  • Assignment
  • In the assignment assign the value to the variable or assign variable to the variable
    Ex:int x;
         x=12;(value to variable)
         int y;
         y=x;(variable to variable)


    Datatypes

    Datatypes are used to identify the type of data or which allocates the sufficient memory space for the varables. These Datatypes are classified into following types:
    1. Primitive Datatypes
    2. Derived Datatypes
    3. Userdefined Datatypes
  • Primitive Datatypes:
  • Primitive datatypes are used to store the single value at a time
    Ex:int x=12;
        int y=12,13;(invalid) These Primitive datatypes are classified into following types
    1. Integer datatype
    2. Floating point datatypes
    3. Character datatypes
    4. Void Datatypes
  • Derived Datatypes:
  • These are used to store the morethan one value similar type
    Ex:Arrays--- int marks[]={12,12,12,12,12,12}
  • Userdefined Datatypes:
  • These are used to store the morethan one value dissimilar type
    Ex:structure,union
  • Type def : Defined as type definition by using typedef we can create new datatype. Typedef type data _ame;
    Type ---- datatype
    Dataname---- Name of that type



  • No comments:

    Post a Comment