A Quick Look to C-programming Concepts
1.0 OVERVIEW OF C PROGRAMMING
- C language is one of the most popular computer languages today because it is a structured,high level, machine independent language.
- C is called a high level,compiler language. The aim of any high level computer language is to provide an easy and natural way of giving a programme of instructions to a computer.
- C is one of a large number of high level languages which can be used for general purpose programming, i.e., anything from writing small programs for personal amusement to writing complex applications.
- C allows meaningful variable names and meaningful function names to be used in programs without any loss of efficiency and it gives a complete freedom of style, it has a set of very flexible loop constructions and neat ways of making decisions.
- Another feature of C is the way it can express ideas concisely.
- The richness of a language shapes what it can talk about. C gives us the apparatus to build neat and compact programs.
- C tries to make the best of a computer by linking as closely as possible to the local environment.
- The C compiler combines the capabilities of an assembly language with the features of a high-level language and therefore it is well suited for writing both system software and business packages.
- Programs written in C are efficient and fast.
- This is due to its variety of data types and powerful operators.
- C is highly portable. This means that C programs written for one computer can be run on another with little or no modification. Another feature of C is its ability to extend itself.
1.1 INTRODUCTION
C is a remarkable language. Designed originally by Dennis Ritchie, working at AT&T Bell
Laboratories in New Jersey, it has increased in use until now it may well be one of the most widely-
written computer languages in the world. C is a structured language. It allows variety of programs
in small modules. It is easy for debugging, testing, and maintenance if a language is a structured
one.
1.2 STRUCTURE OF A C PROGRAM
Include header file section
Global declaration section
main()
{
Declaration part
Executable part
}
User-defined functions
{
Statements
}
Include Header File Section
C program depends upon some header files for function definition that are used in program.
Each header file by default is extended with .h. The header file should be included using # include
directive as given here.
Global Declaration
This section declares some variables that are used in more than one function. These variables
are known as global variables. This section must be declared outside of all the functions.
Function Main
Every program written in C language must contain main () function. The function main() is
a starting point of every C program. The execution of the program always begins with the function
main ().
Declaration Part
The declaration part declares the entire variables that are used in executable part. The
initialisations of variables are also done in this section. Initialisation means providing initial value
to the variables.
Executable Part
This part contains the statements following the declaration of the variables. This part conatins
a set of statements or a single statement. These statements are enclosed between the braces.
User Defined Function
The functions defined by the user are called user-defined functions. These functions are
generally defined after the main () function.
1.3 STEPS FOR EXECUTING THE PROGRAM
1. Creation of program
Programs should be written in C editor. The file name does not necessarily include extension
C. The default extension is C.
2. Compilation of a program
The source program statements should be translated into object programs which is suitable
for execution by the computer. The translation is done after correcting each statement. If
there is no error, compilation proceeds and translated program are stored in another file
with the same file name with extension “.obj”.
3. Execution of the program
After the compilation the executable object code will be loaded in the computers main
memory and the program is executed.
1.7 IDENTIFIERS
Identifiers are names of variables, functions, and arrays. They are user-defined names,consisting sequence of letters and digits, with the letter as the first character.
1.8 CONSTANTS
Values do not change during the execution of the programTypes:
1. Numerical constants:
— Integer constantsThese are the sequence of numbers from 0 to 9 without decimal points or fractional
part or any other symbols. It requires minimum two bytes and maximum four bytes.
Eg: 10,20, + 30, – 14
— Real constants
It is also known as floating point constants.
Eg: 2.5, 5.342
2. Character constants:
— Single character constantsA character constant is a single character. Characters are also represented with a
single digit or a single special symbol or white space enclosed within a pair of single
quote marks
Eg: ‘a’, ‘8’, “ ”.
— String constants
String constants are sequence of characters enclosed within double quote marks.
Eg: “Hello”, “india”, “444”
Want to learn more then please click on ==>>Next