Saturday, 4 August 2012

Data Types in C



  • Data:-
                  The values given to the program to perform various operations on it, is referred to as data.

  • Types of Data in C:-

                          The data type defines the set of values and a set of operations that can be performed on those values. The data is given to the program as input. The data is processed according to the program instructions and output is returned.
                                 In program designing, the data and its types are defined before designing the actual program used to process the data. The values or data used in a program may be of different types. In a C program, each variable is associated with a specific data type.
                       C language provides standard data types. A standard data type is one of that is predefined in the language.

  • For Example:-

  1. int
  2. float
  3. double
  4. char
C language also allows the user to define its own data types known as user defined data types.

Types of Identifiers



  • Types of Identifiers:-
                 There are two types of Identifiers in C. These are:
  1. Standard Identifier
  2. User defined Identifier

  • Standard Identifier:-
                          Like keywords, there are also predefined identifiers in C. The predefined identifiers of the C language that are used for special purposes in the source program are called the standard Identifier. Each identifier has special meanings in C. The names used for standard library functions are standard identifiers.
  • For Example:-
                  In C program, the scanf() and printf() functions are mostly used for input or output operations. Therefore, the functions names ''scanf'' or "printf" are examples of standard identifiers.
  • User Defined Identifiers:-
                         The user (or programmer) can define its own identifiers in the C program such as variables, user defined functions, labels etc. The Identifiers defined by the user in the program are called user defined IdentifiersC is a case sensitive language. 
  • For Example:-
                    The C compiler considers 'Area' and 'area' as two different identifiers.

Wednesday, 1 August 2012

Identifier



  • Identifier:-
                     The unique names used in the program to represent the variables, constants, functions and labels etc. are called Identifiers. You can use any number of characters for the name of an identifier but only the first 31 characters are significant to the C compiler. 

  • Types of Identifiers:-
              There are two types of identifiers in C. These are:

  1. Standard Identifier
  2. User-Defined Identifier

Token


  • Token:-
               In C-language, a source program consists of keywords, variables (or identifiers), constants, operators, punctuators etc. These elements of a program known as tokens.

  • For Example:-
                    main()
                    {
                          float temp, xy4;
                          xy4 = 10;
                          temp = xy4 + 10 * 2;
                    }


                 In the above program;

  1. ''main'' is a special identifier and temp, xy4 are variables.
  2. ''float'' is a keyword.
  3. The punctuators are; { , " , '' , ( , ) , ; , white spaces etc.
  4. The operators are : , = , *  , + , etc.

Keywords of C language


  • Keyword:-
            The predefined words of the C-language that are used for special purposes in the source program are called keywords. Keywords are also known as reserved words. 
  • For Example:-
  keyword "int" is used to define the integer type variables.


                Each keyword has certain meanings in C language. They cannot be redefined or used in other ways. They cannot be used as variable or function names. Keywords are always written in lowercase's. There are 32 keywords in C.
    The ''main'' is not the keyword. It is a special identifier that indicates the beginning of the program.

  • C LANGUAGE KEYWORDS:-