Professional Documents
Culture Documents
Features of C-Language
1. Modularity.
2. Portability.
3. Middle Level.
4. Powerful
6. Flexibility.
Modularity: Ability to breakdown a large module into manageable sub modules called as
modularity that is an important feature of structured programming languages.
Advantages:
Portability:
C Programs are portable i.e they can be run on any Compiler with Little or no
Modification.
Compiler and Preprocessor make it Possible for C Program to run it on Different PC.
Middle Level:
‘C’ is also called as middle level language because programs written in ‘c’ language run
at the speeds matching to that of the same programs written in assembly language so ‘c’
language has both the merits of high level and middle level language and because if this feature
it is mainly used in developing system software.
Powerful
Flexibility
This feature refers to the programmer’s involvement and control on the language. There
are number of reserve words in C Language which help the programmer to take control over the
usage of language and modified the structure of program.
Applications of C-Language
Structure of a C-Program
The documentation section consist of a set of comment lines giving the name of the
program, the author name and other details, which the programmer would like to use later.
The preprocessor statement begins with # symbol and is also called the preprocessor
directive. These statements instruct the compiler to include C preprocessors such as header files
and symbolic constants before compiling the C program. Some of the preprocessor statements
are listed below.
The variables are declared before the main ( ) function as well as user defined functions is
called global variables. These global variables can be accessed by all the user defined functions
including main ( ) function.
Each and Every C program should contain only one main ( ). The C program execution
starts with main ( ) function. No C program is executed without the main function. The main ( )
function should be written in small (lowercase) letters and it should not be terminated by
semicolon.Main ( ) executes user defined program statements, library functions and user defined
functions and all these statements should be enclosed within left and right braces.
Local Declarations
The variable declaration is a part of C program and all the variables are used in main ( )
function should be declared in the local declaration section is called local variables.
Program statements
These statements are building blocks of a program. They represent instructions to the
computer to perform a specific task (operations). An instruction may contain an input-output
statements, arithmetic statements, control statements, simple assignment statements and any
other statements and it also includes comments that are enclosed within /* and */ . The comment
statements are not compiled and executed and each executable statement should be terminated
with semicolon.
These are subprograms, generally, a subprogram is a function and these functions are
written by the user are called user defined functions. These functions perform user specific tasks
and this also contains set of program statements. They may be written before or after a main ()
function and called within main () function. This is an optional to the programmer.
5. No restriction in using blank spaces or blank line in program segments. But spaces not
allowed within variable, constant or keyword.
6. Comments cannot be nested. For example
/* A simple ‘C’ program, /* it prints a message */ */ is not valid.
7. A comment can be split into more number of lines.
8. The global variables can be declared outside of all functions.
Create a text file using any word processing software with its name end with a C
extension and type a C program in that file. Various C-compilers are available under DOS
wizard. Quick C, Microsoft C, Turbo C, ANSI C etc are examples for the C-Compilers.
Compilation of program:
Alt+F9
For example, if file name is “Sample.c”, open the file using Turbo C editor and press
Alt+F9 in keyboard. If no errors found it will produce object file i.e., Sample.obj(It is the
machine understandable file).
Program execution:
In Turbo C environment, the RUN option will do the execution of program. Ctrl+F9 is
short cut key from keyboard to run program. After completing the execution of the C-Program, it
generates the desired output to our program with respect to the given input. And the resultant file
is Sample.exe.
C-Character Set
The character set is used to form words, numbers and expressions depending upon the
computer on which the programs run. The characters in the C are categorized in the following
way.
Letters A to Z, a to z.
Meani
Symbol Symbol Meaning Symbol Meaning Symbol Meaning
ng
Lest
~ Tilde - Minus sign ( ; Semicolon
parenthesis
Exclam Opening
Equal to Right
! ation = ) < angle
sign parenthesis
mark bracket
Closing
Numbe
# { Left brace _ Underscore > angle
r sign
bracket
Dollar Question
$ } Right brace + Plus sign ?
sign mark
Percent Left Vertical
% [ | , Comma
sign bracket bar
Right
^ Caret ] \ Backslash . Period
bracket
Ampers
& : Colon ` Apostrophe / Slash
and
Asteris Quotation
* "
k mark
Delimiters in C
Delimiter Purpose
: Useful for labeling
; Statement termination symbol
{} Justifies the scope of the variable
() To define function and function call
[] Used for array declaration.
# Preprocessor Directive.
, Variable Separator.