- C is a structured programming language with fundamental flow control construction.
- C is simple and versatile language
- Programs written in C are efficient and fast.
- C has only 32 keywords.
- C is highly portable programming language. The programs written for one computer can be run on another with or without any modifications
- C has rich set of operators.
- C permits all data conversions and mixed mode operations
- Dynamic memory allocation(DMA) is possible in C.
- Extensive varieties of data types such as arrays, pointers, structures and unions are available in C.
- C improves by itself. It has several predefine functions.
- C easily manipulates bits, bytes and addresses.
- Recursive function calls for algorithmic approach is possible in C.
- Mainly we are using C language to implement system softwares. These are compilers ,editors, drivers ,databases and operating systems.
- C compiler combines the capability of an assembly level language with the features of high level language. So it is called as middle level language.
NOTE :
- C was basically designed for Unix operating system. 93% of instructions, which are written in C.
- C is case sensitive programming languae. C statements are entered in lower case letters only.
- C is function oriented programming language. Any C program contains one or more functions . Minimum One function is compulsory by the name called Without main we can’t execute a C program.
- Every C statement must be terminated by semicolon ( ; ), except pre-processor statements and function definition.
- A function is represented by function name with a pair of parenthesis ( ).
Execution of C program :
Once the program is completed, the program is feed into the computer using the compiler to produce equivalent machine language code. In C program compilation there are 2 mechanisms.
- Compiler
- Linker
Compiler receives the source file as input and converts that file into object file. Then the Linker receives the object file as its input and linking with C libraries. After linking it produces an executable file for the given code. After creation of executable file, then start the program execution and loads the information of the program into primary memory through LOADER. After loading the information the processor processing the information and gives output.
Basic structure of C program :
Document section :
It consists a set of comment lines giving the name of the program, author name and some other details about the entire program.
Preprocessor Section (or) Link section :
It provides instructions to the compiler to link the functions from the system library.
Global declaration Section :
The Variables that are used in more than one function are called as global variables and these are declared in global declaration section.
Main Function section :
Every C program must have one function. i.e. main function. This section contains 2 parts.
- Local declaration section.
- Statements .
The Local declaration section declares all the variables used in statements. The statements part consists a sequence of executable statements.These 2 parts must appear between opening and closing curly braces. The program execution begins at the opening brace and ends at closing brace.
Sub programming section:
It contains all the user defined functions.
This section may be placed before or after main function.
Comments:
Unexecutable lines in a program are called as comments. These lines are skipped by the compiler.
/* */ Multi line comment.
//………. single line comment(C++ comment).
Preprocessor statements :
The preprocessor is a program that process the source code before it passes through the compiler.
#include:
It is preprocessor file inclusion directive and is used to include header files. It provides instructions to the compiler to link the functions from the system library.
Syntax:
#include ” file_name ”
(or)
#include < file_name >
When the file name is included within the double quotation marks, the search for the file is made first in the current directory and then the standard directories(TC). Otherwise when the file name is included within angular braces, the file is search only in standard diretories(TC).
stdio.h :- standard input and output header file.
conio.h :- console input and output header file.
console units: keyboard and monitor.
These 2 headers are commonly included in all C programs.
If you want to work with Turbo c/c++ ,first install Turbo c/c++ software and then follow the following steps.
Steps involved in C programming:
1) How to open a C editor(windows xp):
- Start Menu à Run à type C:\TC\Bin\TC.exe then press Enter key
- At the time of installation create Shortcut to C on Desktop, then it will create an icon(TC) on desktop. Double click on that icon.
How to open a C editor(windows 7):
- At the time of installation it creates Shortcut to C (turboc++)on Desktop. Double click on that icon.
2) After entering into C editor, check the path as:
goto Options menu à Directories Ã
windows xp
- C :\TC\Include
- C :\TC\Lib
- —————–
- —————–
windows 7
- C :\Turboc3\Include
- C :\Turboc3\Lib
- —————–
- —————–
3) Type C program , goto File menu à New
4) Save program , goto File menu à Save
5) Compile Program ,
goto Compile menu à Compile
6) Run the Program , goto Run menu à Run
7) See the output ,
goto window menu -> user screen
8) Exit from C editor , goto File menu à Quit
0 Comments
If you have any doubts,please let me know