2. Outline
2
INTRODUCTION OF C LANGUAGE
IMPORTANCE OF C
PRINT THE SIMPLE PROGRAM IN C LANGUAGE
BASIC STRUCTURE OF C PROGRAMS
PROCESS OF COMPILING AND RUNNING A C
PROGRAM
C ENVIRONMENT SETUP
WHY TO USE C ?
WHAT ARE THE BENEFITS OF THE LEARNING C
PROGRAMMING
WHY WE SAY C IS MIDDLE LEVEL LANGUAGE??
3. 3
INTRODUCTION OF C LANGUAGE
C is a procedural programming language. It was initially developed by Dennis Ritchie
between 1969 and 1973. It was mainly developed as a system programming language
to write operating system. The main features of C language include low-level access
to memory, simple set of keywords, and clean style, these features make C language
suitable for system programming like operating system or compiler development.
Many later languages have borrowed syntax/features directly or indirectly from C
language. Like syntax of Java, PHP, JavaScript and many other languages is mainly
based on C language. C++ is nearly a superset of C language (There are few
programs that may compile in C, but not in C++).
4. 4
A Brief History of C
C is a general-purpose language which has been closely associated with the UNIX
operating system for which it was developed - since the system and most of the
programs that run it are written in C.Many of the important ideas of C stem from the
language BCPL, developed by Martin Richards. The influence of BCPL on proceeded
indirectly through the language B, which was written by Ken Thompson in 1970 at
Bell Labs, for the first UNIX system on a DEC PDP-7. BCPL and B are "type less"
languages whereas C provides a variety of data types.In 1972 Dennis Ritchie at Bell
Labs writes C and in 1978 the publication of The C Programming Language by
Kernighan & Ritchie caused a revolution in the computing world.In 1983, the American
National Standards Institute (ANSI) established a committee to provide a modern,
comprehensive definition of C. The resulting definition, the ANSI standard, or "ANSI
C", was completed late 1988.
5. 5
It is robust language whose rich setup of built in functions and operator can be used
to write any complex program.
Program written in C are efficient due to several variety of data types and powerful
operators.
The C compiler combines the capabilities of an assembly language with the feature
of high level language. Therefore it is well suited for writing both system software
and business package.
There are only 32 keywords; several standard functions are available which can be
used for developing program.
IMPORTANCE OF C LANGUAGE
6. 6
C is portable language; this means that C programs written for one computer
system can be run on another system, with little or no modification.
C language is well suited for structured programming, this requires user to think of a
problems in terms of function or modules or block. A collection of these modules
make a program debugging and testing easier.
C language has its ability to extend itself. A c program is basically a collection of
functions that are supported by the C library. We can continuously add our own
functions to the library with the availability of the large number of functions.
In India and abroad mostly people use C programming language because it is easy
to learn and understand.
8. 8
Above programe
Output is here
#include<stdio.h>
#include<conio.h>
Is called Header file stadio.h “stands for "standard input output” and “conio.h
provide console input output”
main() is called function
main() function is the entry point of any C program. It is the point at which
execution of program is started. When a C program is executed, the execution
control goes directly to the main() function. EveryC program have a main()
function.
9. 9
printf()
Printf format string (of which "printf" stands for "print formatted") refers to a
control parameter used by a class of functions in the string-processing libraries
of various programming languages.
;
Is Called Semicolon and Every C Statement in C should end with a semicolon(;)
mark.
Note :remaining thing we study next chapter
11. 11
Documentation Section
This section consists of comment lines which include the name of programmer, the
author and other details like time and date of writing the program. Documentation
section helps anyone to get an overview of the program.
Link Section
The link section consists of the header files of the functions that are used in the
program. It provides instructions to the compiler to link functions from the system
library.
12. 12
Definition Section
All the symbolic constants are written in definition section. Macros are known as
symbolic constants.
Global Declaration Section
The global variables that can be used anywhere in the program are declared in
global declaration section. This section also declares the user defined functions.
13. 13
main() Function Section
It is necessary have one main() function section in every C program. This section
contains two parts, declaration and executable part. The declaration part declares
all the variables that are used in executable part. These two parts must be written
in between the opening and closing braces. Each statement in the declaration and
executable part must end with a semicolon (;). The execution of program starts at
opening braces and ends at closing braces.
14. 14
Subprogram Section
The subprogram section contains all the user defined functions that are used to
perform a specific task. These user defined functions are called in the main()
function.
16. 16
C ENVIRONMENT SETUP
C Compiler is a program that converts human readable code into machine
readable code. This process is called compilation.
Human readable code is a program that consists of letters, digits and special
characters that we type in program window. Machine readable code is in 0’s &
1’s
For example, let’s assume that we type ” HELLO” in program window. We know
that we have typed “HELLO” in program window.
But, processor knows only 01001000 for letter “H”, 01000101 for letter “E”,
01001100 for letter “L”, 01001100 for letter “L”, 01001111 for letter “O”
17. 17
Because, all C programs are executed by processor which is available in CPU
So, entire C source code should be converted into 0’s and 1’s as processor can
understand only 0’s and 1’s.
So, compiler converts entire source code into 0’s and 1’s during compilation.
Output produced by compiler is in the form of 0’s and 1’s which is saved in .exe
file. This file is called as executable or binary file.
This binary file is executed by processor as per logic written in source code and
the output is displayed in output window.
18. 18
There are so many compilers available in market for Windows operating system.
We are listing some of them here for your reference.
1. GCC compiler
2. clang
3. Cygwin
4. Digital mars
5. MikroC Compiler
6. Portable C Compiler, Power C, QuickC, Ritchie C Compiler, Small-C etc..
19. 19
Nowadays, both C and C++ compilers are integrated together in same
development environment.
For example, Turbo C++, Code Block Borland C++ and DevC++ provides
Integrated Development Environment with compiler for both C and C++
programming language.
So, we can compile and execute both C and C++ programs in same Integrated
Development Environment (IDE).
here we have see process how to install code block step by step guide and you
can also install as per above IDE for required you have any one of them install
your machine like code block , for c and c++ program to be execute
26. 26
WHY DO WE USE C LANGUAGE ???
It was (and still is in some circumstances) the language of choice in Operating
System Development (including all of Unix).
It allows you direct control over the very low level aspects of the computer.
Many legacy programs are written in C.
Most of the things you learn with C will be directly transferable to future
programming languages
Programs that are created with C run very quickly.
27. 27
The programs you create in C will run "standalone". All of the programs we
wrote in Matlab, need Matlab in order to work, and if you don't have access to
Matlab, you are out of luck. C programs, once compiled into "executables", can
be transferred to other (similar) machines, and run without the need for the
source code.
Many of the codes you will use in your future work/studies will have been written
in C. You should at the least, be able to read them. And hopefully, you will be
able to maintain, modify, and update them.
28. 28
WHAT ARE THE BENEFITS OF THE LEARNING
C PROGRAMMING
As a middle level language, C combines the features of both high level and low
level languages. It can be used for low-level programming, such as scripting for
drivers and kernels and it also supports functions of high level programming
languages, such as scripting for software applications etc.
C is a structured programming language which allows a complex program to be
broken into simpler programs called functions. It also allows free movement of
data across these functions.
29. 29
Various features of C including direct access to machine level hardware APIs,
presence of C compilers, deterministic resource use and dynamic memory
allocation make C language an optimum choice for scripting applications and
drivers of embedded systems.
C language is case-sensitive which means lowercase and uppercase letters
are treated differently.
C is highly portable and is used for scripting system applications which form a
major part of Windows, UNIX and Linux operating system.
30. 30
C is a general purpose programming language and can efficiently work on
enterprise applications, games, graphics, and applications requiring calculations
etc.
C language has a rich library which provides a number of built-in functions. It also
offers dynamic memory allocation.
C implements algorithms and data structures swiftly, facilitating faster
computations in programs. This has enabled the use of C in applications requiring
higher degrees of calculations like MATLAB and Mathamatica.
31. 31
WHY WE SAY C IS MIDDLE LEVE LANGUAGE?
C combines the features of both Assembly Level Languages (Low Level
Languages) and Higher Level Languages. For this reason, C is referred to as a
Middle Level Language. The feature of ALLs is that of enabling us to develop
system level programs and the features of HLLs are those of higher degree of
readability and machine independence.
C Programming Supports Inline Assembly Language Programs .
Using inline assembly language feature in C we can directly access system
registers.
C Programming is used to access memory directly using pointer.
32. 32
C Programming also Supports high Level Language Features.
It is more User friendly as compare to Previous languages so C
programming is Middle Level Language.