features of c programming language

Upload: peter-banda

Post on 08-Apr-2018

225 views

Category:

Documents


0 download

TRANSCRIPT

  • 8/7/2019 Features of C Programming Language

    1/4

    Features of C

    a) Middle Level Language : C is thought of as a middle level language because it combineselements of high-level language with the functionalism of assembly language. C allowsmanipulation of bits, bytes and addresses - the basic elements with which the computer functions.

    Also, C code is very portable, that is software written on one type of computer can be adapted towork on another type. Although C has five basic built-in data types, it is not strongly typedlanguage as compared to high level languages, C permits almost all data type conversions.

    It allows direct manipulation of bits, bytes, words, and pointers. Thus, it is ideal for system level-programming.

    b) Structured Language : The term block structured language does not apply strickly to C.Technically, a block-structured language permits procedures and function to be declared insideother procedures or functions. C does not allow creation of functions, within functions, andtherefore cannot formally be called a block-structured language. However, it is referred to as astructured language because it is similar in many ways to other structured languages like ALGOL,

    Pascal and the likes.

    C allows compartmentalisation of code and data. This is a distinguishing feature of any structured

    language. It refers to the ability of a language to section off and hide all information andinstructions necessary to perform a specific task from the rest of the program. Code can becompartmentalised in C using functions or code blocks. Functions are used to define and codeseparately, special tasks required in a program. This allows programs to be modular. Code blockis a logically connected group of program statements that is treated like a unit. A code block iscreated by placing a sequence of statements between opening and closing curly braces.

    c) Machine Independent (Portability of Code) : The code written in c is machine independent

    which means, there is no change in C instructions, when you change the Operating System orHardware. There is hardly any change required to compile when you move the program from oneenvironment to another.

    Eg. Program written in DOS Operating System can be easily compiled on UNIX operating systemby copying the source code on to the UNIX operating system and compiling it over there.

    d) Fast Speed ( Better Performance ) : The execution speed of programs written in C is veryfast since the statements are converted to few machine instructions which directly go into theprocessor for implementing the task.

    e) Keywords with Libraries : The Original C ( developed by Dennis Ritche ) is having only 32keywords to perform all tasks which sometimes makes programming very tedious. But now wehave ready made libraries of functions which can be used to perform simple tasks very easilywithout much of the coding. Library functions like printf() and scanf() can be used for Input andOutput, they belong to stdio (Standard Input Output ) library.

  • 8/7/2019 Features of C Programming Language

    2/4

    f. Compiler Language : C Language uses COMPILER to translate your instruction code to

    machine code. Compiler takes the text source code and coverts to object code and then Linker( part of compiler only ) converts it to executable code by taking reference of Library.

    The various well-known compilers available for C are

    o Turbo C

    o Borland C

    o Microsoft C

    Note : Though there is only small difference in all these compilers, Lets make itclear that this tutorial will deal with Turbo C 2.0

    A simple c program

    /* my first c program */

    main()

  • 8/7/2019 Features of C Programming Language

    3/4

    {

    printf("hello world");

    }

    In Turbo C compiler following shortcut keys are used

    Keys Operation

    F9 Compile Only

    Ctrl F9 Compile & run

    Alt F5 To see Output Screen

    F2 Save the File

    Alt X Exit Turbo C

    F3 Load File

    Alt F3 Pick File from List

    Explaination of the program written above :

    ; as statement terminator : In C ; is used as statement terminator. That means we can write asmany statements as we want on a single line since statement is not terminated with new line

    character.

    Case sensitive : C is very sensitive as far as Case is concerned. var & VAR are two differententities in c. One should remember in what case the variable were declared. For convenienceeverything is declared in lower case only.

  • 8/7/2019 Features of C Programming Language

    4/4

    Starts with main() function

    Block of statements ( { for beginning of block & } for end of block )

    /* */ for writing comments in program.

    main()

    {

    printf("C was developed");

    printf("\nDennis Ritchie");

    }

    Escape Sequences

    Character Meaning Example Output

    \n New line Hello \nWorld Hello

    World

    \t Tab Hello \tWorld Hello World

    \r Return Hello \rMe Mello

    \a Alert ( beep sound ) Hello \aworld Hello world

    \0 Null Hello \0 World Hello