Showing posts with label C. Show all posts
Showing posts with label C. Show all posts

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:-



Tuesday, 31 July 2012

Character Set of C


  • Character Set of C:-
                              Every programming language has its own set of characters which are used to write the statements of the program (source code). In C language also, a program is written by using a set of characters. These characters are known as alphabet or character set of C. The alphabet of C language is given below.
  1. Lowercase letters: a, b, c, ........, z
  2. Uppercase letters: A, B, C, ............, Z
  3. Digits: 0, 1, 2, ............, 9
  4. Special characters: +, -, /, =, (, ), [, ], {, }, <, >, ', ", !, @, #, $, %, \, /, ;
  5. White Spaces: blanks, new line, tab etc.

Tuesday, 22 May 2012

Constant Macro, Delimiters, Statement Terminator

Dear Members,
    In this lesson we give you a concept about Constant Macro, Delimiters, Statement Terminator and its importance in C program.

  • Constant Macro:-
                        The 'define' directive is an important preprocessor directive. It is used to define a constant known constant macro. A constant macro is an identifier, which is assigned a particular constant value. The value of identifier remains constant during the execution of program.

  • Delimiters:-

                            The body of the function is surrounded by braces (or curly brackets { and } ). These braces are called delimiters. The left brace indicates the start of the body of the function, whereas the matching right brace indicates the end of the body by the function.

    • Statement Terminator:-
     
                                Every statement of C program must be terminated with semicolon ( ; ). It is called statement terminator. If any of the statement is missing the statement terminator ( ; ), the following error message will be shown by compiler during compiling process.
    Statement missing;

    Sunday, 4 March 2012

    Preparation of C Program for Execution



    Dear readers,
                  In this lesson we tell you about the some necessary steps to prepare C program for execution..
    SO FRIENDS LETS START LESSON
    • Some steps which are taken to prepare a C program for execution are :-
    1. Creating & Editing C Program
    2. saving C program
    3. Compiling C program
    4. Linking C program
    5. Loading C program
    6. Executing C program
    • Creating & Executing C program :-
                                                       The first step is to create and edit the source program in C. The C program is usually and edited in Turbo C editor.
    • Saving C program :-
    After writing or editing the source program, it is saved on the disk as text file with an extension ".c".
    • Compiling C program :-
    In this step, the source program is compiled. The source program is converted into machine code. The C compiler is used to translate  the C program source code into the machine code.
    • Linking C program :-
    In this step, the Linker links object file produced by the compiler to many other library files.
     After linking the object code  to the libraries, an executable file with extension EXE is created.
    • Loading C program :-
                        In this step the loader loads the executable file from disk into memory for execution. The program must be loaded into memory for execution.

    • Executing C program :-
    In this step, the program is executed on the computer. The CPU fetches instructions of program from memory one by one and takes action on them.


    Monday, 20 February 2012

    Executing C Program


    Dear readers,
         After successfully learn the compiling C program and linking C program lessons. You are now ready to learn how to execute C program on your computer. 
    SO FRIENDS LETS START LEARNING
    • Executing C program :-
                                The process of running the program on computer is called executing. The program must be loaded into memory for execution. This work is done by the Loader. Loader is a program that loads the executable file from disk into memory.
    For Example :-
                 In Windows environment, when the name of an executable file is double clicked. The Loader loads the file into the computer memory for execution on the CPU.
    In TC Editor, you can compile and run the program by pressing the shortcut key Ctrl+F9 or by selecting Run command from Run menu of Turbo C IDE. The program is first compiled and then run on the computer.
                       When the program is run, the program's output  is printed on the screen but not to the IDE window. To see the program's output, select "User screen" command from the window menu, or press keyboard shortcut Alt + F5. You will see normal DOS screen with program output (if any).
          Some errors may occur during the execution of the program. These errors are called the execution errors. These errors may halt the system.

    Linking C Program


    Dear readers,
                   In this post you will learn the method to link a C program....
    SO FRIENDS LETS START LEARNING
    • Linking C program :-
                   Linking is a process in which the object file produced by the compiler is linked to many other library files. This work is done by the Linker.
     The Linker is a program and is a part of compiler. After linking the object code to the libraries, an executable file with extension EXE is created.
    For example :-
                If  source file name is "test.c", then executable file name will be "test.exe".
                          In Turbo C environment, program is linked as;
    • Select Link command from Compile menu on the menu bar.
     
    In Turbo C IDE, compiling and linking can be performed together in one step. To do this, select Make command from Compile manu or press F9 key. The linker can also detect errors.
    • For Example :-
    If the source code uses a library function that does bot exist, the linker generates an error. If there is any error in the source code, the Linker will not create the executable file.
     In this case, the errors are removed from the source code and source code is compiled again. The new object file is then linked to the libraries to create the executable file. The file directly dun on the computer.

    Tuesday, 3 January 2012

    Source Code & Object Code



    • Source Code:-
                                          The Program instructions written by following the rules of any High Level Language are known as Program Source Code. The source code is like English statements but the computer understands only the instructions in Machine code.
    • Object Code:-
                                  A computer understands only the machine code. The source program written in any High Level Languages (and assembly language) must be translated into machine code before running it on the computer. The translated program into machine code is known as Program Object Code.