Introduction to C Programming
C programming is a
General-purpose programming language is not a very high-level
language nor low level it is a middle-level language,
originally designed for implementation of Unix operating system by Dennis
Ritchie in 1972, Most of the ideas of C programming is from the language BPCL
which was developed by Martin Richards. Effect of BPCL on C programming
processed indirectly through the language B, it was written by Ken Thompson in
1970 for the first Unix operating system.
until 1978 C was only used in
Bell Laboratories, in 1978 Brian Kernighan and Ritchie published a
description of a C programming language, computer professionals are impressed
with C as its having many desirable features to enhance programming
skills by the mid-1980 popularity of the C programming language increased as it used
tools for working programmers later on it is used as a programming
language, In 1983 a committee was
established to create an ANSI (American National
Standards Institute) which defined the C language and after six years in December
1989 ANSI C standard was adopted. First copy available
in 1990 and in 1995 The standard was also adopted by ISO (International
Standards Organization) and it is referred to as ANSI/ISO Standard.
Features of C programming
It is simple and easy to use the programming language, C is a reliable, case-sensitive language.
It supports the concept of modular
programming.
Basic Structure of C Program program structure
C Program Basically consists of the following parts:
- Preprocessor
commands
- Functions
- Variables
- Statements
and Expressions
- Comments
FFirst C Program:
# Include is command Which tells the
compiler to include a particular file to include the content of a stdio.h file
in the program converts the high-level language to the low-level language.
\n is for a new line it means after the execution of the program cursor will move to the next line.
return 0 is used to exit status.
How to compile and execute the c program
By using two methods we can compile and
execute the c program, by using a menu of Turbo C software and by shortcut
keys of your keyboard.
By menu execution
We need to click on the compile
menu of Turbo C software then drag
to compile sub-menu and click on compile the c program.
After compilation, if any error present in the program compiler will give you an error message or warning message, we need to resolve this error or warning.
if there is no error or warning it will
show one message your program compiled successfully with zero errors.
then click on
the run menu of Turbo C software then
run sub-menu and click on run
By shortcut key
execution
By just pressing the Alt+f9 keys you can compile and pressing the ctrl+f9 keys you can run the program directly.
You can see the output on the console
screen.
Process of execution
Pre-processor: as we design the program in high-level language its need to be converted into a machine language so first preprocessor delete all the comments from the program as comments are not a part of the coding we just place comments in coding for future reviews and anyone can understand our code, Processor directive Expanded modified source program header files included and this will gives pure high-level language code and this code is transfer to the compiler.
Compiler: Compiler receive expanded code from preprocessor and convert source program into machine code, Compiler working is same for all machine architecture with specific changes in the machine.
Assembler: the assembly code is converted into object code by using an assembler, check file generated by the assembler is the same as the source file.
the extension of the object file in DOS is’ obj’ and in Unix operating system, the extension is ’o’.
if the filename of your source code is program1.c then the name of the object file included is program1.obj.
Linker: the main task of the
linker is to combine the object code of the library file with the object code of a
our program, pre executed library files will be stores on your machine at the
time of installation of C Programming software. For
example, if we are using getch(), clrscr() function in a program,
then the linker links its associated code in an output file. So
linker basically is to link the object code of our program with the object code
file of the library files.