1. C PROGRAMMING
COURSE CODE:19UAKCT101
COURSE NAME : Programming in C
UNIT 1
overview of c-history of c-importance of c- constants,
variables-character set-C Tokens-Key words and
Identifiers-Constants and variables-Data types
Managing Input and Output Operations-Reading a
Character-Writing a Character-Formatted Input-
Formatted Output-operators and expressions.
2. C PROGRAMMING
• C is a general-purpose, high-level language that was originally
developed by Dennis M. Ritchie to develop the UNIX operating
system at Bell Labs. C was originally first implemented on the DEC
PDP-11 computer in 1972.
• In 1978, Brian Kernighan and Dennis Ritchie produced the first
publicly available description of C, now known as the K&R standard.
• The UNIX operating system, the C compiler, and essentially all
UNIX application programs have been written in C. C has now
become a widely used professional language for various reasons −
• Easy to learn
• Structured language
• It produces efficient programs
• It can handle low-level activities
• It can be compiled on a variety of computer platforms
3. C PROGRAMMING
• Facts about C
• C was invented to write an operating system called UNIX.
• C is a successor of B language which was introduced around
the early 1970s.
• The language was formalized in 1988 by the American
National Standard Institute (ANSI).
• The UNIX OS was totally written in C.
• Today C is the most widely used and popular System
Programming Language.
• Most of the state-of-the-art software have been implemented
using C.
• Today's most popular Linux OS and RDBMS MySQL have
been written in C.
4. C PROGRAMMING
Why use C?
C was initially used for system development work, particularly the programs
that make-up the operating system. C was adopted as a system development
language because it produces code that runs nearly as fast as the code written
in assembly language. Some examples of the use of C might be −
Operating Systems
Language Compilers
Assemblers
Text Editors
Print Spoolers
Network Drivers
Modern Programs
Databases
Language Interpreters
Utilities
5. C PROGRAMMING
• C Programs
• A C program can vary from 3 lines to millions of lines and
it should be written into one or more text files with
extension ".c"; for example, hello.c.
6. Importance of C
• Structured , high level, Machine independent language.
• It is a robust language whose rich set of built in functions
and operators can be used to write any complex
program.
• C language is suitable for writing both system software
and business package.
• Many of the c compilers available in market are written in
C.
• C are efficient and fast
• Many times faster than Basic.
• It has 32 keywords and several standard functions are
available.
7. Importance of C
• C is highly portable.
• Feature of C is its ability to extend itself.
• C language is well suited for structured programming
8. Basic Structure of C Programs
DOCUMENT SECTION
LINK SECTION
DEFINITION SECTION
GLOBAL DECLARATION SECTION
Main() Function Section
{
Declaration Part
Executable Part
}
SUBPROGRAM SECTION
FUNCTION 1,2,….N (USER DEFINED FUNCTION)
9. Basic Structure of C Programs
C Program can be viewed as a group of building blocks
called functions.
A function is a subroutine that may include one or more
statements designed to perform a specific task.
Documentation section consists of a set of comment
lines giving the name of the program.-name of the
program , author name
Link Section-Provides instruction to the compiler to link
functions from the system
Definition Section-Defines all symbolic constants.
10. Basic Structure of C Programs
• Some variables that are used in more than
one function .Such variables is called
global variables and declared on the
global declaration section that is outside of
all the functions. This section is also
declares all the user defined functions.
12. C PROGRAMMING
• Every C program must have one main() function
section
• It contains two Parts
• 1.Declaration Part
• 2.Executable Part
Declaration Part-declares all the variables used in
executable part.
There is at least on statement in the executable
part.
13. C PROGRAMMING
• These two parts must appear between
opening and closing braces.
• The program execution begins at the opening
brace and ends at the closing brace.
• The closing brace of the main section is the
logical end of the program.
• All statements in the declaration and
executable part end with semicolon.
14. C PROGRAMMING
• The sub program section contains all user
defined functions that are called in the main
function.
• User defined functions are generally placed
immediately after the main function.
• All sections ,except the main function section
may be absent when they are not required.