Introduction to C
N.V.Raja Sekhar Reddy
www.programming9.com
C-Programming Video Tutorials
Contact the Instructor
programming9info@gmail.com
Contents
www.programming9.com
 Introduction
 Standards
 Terminology in Programming
 Stages of Compilation
 Why C
Introduction
 The C programming language was designed by Dennis
Ritchie at Bell Laboratories in the early 1970s
 Influenced by
 ALGOL 60 (1960),
 CPL (Cambridge, 1963),
 BCPL (Martin Richard, 1967),
 B (KenThompson, 1970)
 Traditionally used for systems programming, though this
may be changing in favor of C++
 Traditional C:
 The C Programming Language, by Brian Kernighan and Dennis
Ritchie, 2nd Edition, Prentice Hall
 Referred to as K&R
www.programming9.com
Standard C
 Standardized in 1989 by ANSI (American National
Standards Institute) known as ANSI C
 International standard (ISO) in 1990 which was adopted
by ANSI and is known as C89
 As part of the normal evolution process the standard was
updated in 1995 (C95) and 1999 (C99)
 C++ and C
 C++ extends C to include support for Object Oriented
Programming and other features that facilitate large software
development projects
 C is not strictly a subset of C++, but it is possible to write
“Clean C” that conforms to both the C++ and C standards.
www.programming9.com
Writing C Programs
 A programmer uses a text editor to create or
modify files containing C code.
 Code is also known as source code.
 A file containing source code is called a source file.
 After a C source file has been created, the
programmer must invoke the C compiler before
the program can be executed (run).
www.programming9.com
3 Stages of Compilation
Stage 1: Preprocessing
 Performed by a program called the preprocessor
 Modifies the source code (in RAM) according to preprocessor
directives (preprocessor commands) embedded in the source
code
 Strips comments and white space from the code
 The source code as stored on disk is not modified.
www.programming9.com
3 Stages of Compilation (con’t)
Stage 2: Compilation
 Performed by a program called the compiler
 Translates the preprocessor-modified source code into object
code (machine code)
 Checks for syntax errors and warnings
 Saves the object code to a disk file, if instructed to do so (we will
not do this).
o If any compiler errors are received, no object code file will be
generated.
o An object code file will be generated if only warnings, not errors, are
received.
www.programming9.com
3 Stages of Compilation (con’t)
Stage 3: Linking
 Combines the program object code with other object code to
produce the executable file.
 The other object code can come from the Run-Time Library,
other libraries, or object files that you have created.
 Saves the executable code to a disk file. On the Linux system,
that file is called a.out.
o If any linker errors are received, no executable file will be generated.
www.programming9.com
Program Development Using gcc
Source File filename.c
Program Object Code File filename.o
Executable File a.out
Preprocessor
Modified Source Code in RAM
Compiler
Linker
Other Object Code Files (if any)
Editor
www.programming9.com
Why to use C ?
www.programming9.com
 Operating Systems
 Language Compilers
 Assemblers
 Text Editors
 Print Spoolers
 Network Drivers
 Modern Programs
 Data Bases
 Language Interpreters
 Utilities
References
www.programming9.com
 Kernighan, BrianW.; Dennis M. Ritchie (February
1978). The C Programming Language (1st ed.). Englewood
Cliffs, NJ: Prentice Hall. ISBN 0-13-110163-3.

Introduction to c

  • 1.
    Introduction to C N.V.RajaSekhar Reddy www.programming9.com C-Programming Video Tutorials Contact the Instructor programming9info@gmail.com
  • 2.
    Contents www.programming9.com  Introduction  Standards Terminology in Programming  Stages of Compilation  Why C
  • 3.
    Introduction  The Cprogramming language was designed by Dennis Ritchie at Bell Laboratories in the early 1970s  Influenced by  ALGOL 60 (1960),  CPL (Cambridge, 1963),  BCPL (Martin Richard, 1967),  B (KenThompson, 1970)  Traditionally used for systems programming, though this may be changing in favor of C++  Traditional C:  The C Programming Language, by Brian Kernighan and Dennis Ritchie, 2nd Edition, Prentice Hall  Referred to as K&R www.programming9.com
  • 4.
    Standard C  Standardizedin 1989 by ANSI (American National Standards Institute) known as ANSI C  International standard (ISO) in 1990 which was adopted by ANSI and is known as C89  As part of the normal evolution process the standard was updated in 1995 (C95) and 1999 (C99)  C++ and C  C++ extends C to include support for Object Oriented Programming and other features that facilitate large software development projects  C is not strictly a subset of C++, but it is possible to write “Clean C” that conforms to both the C++ and C standards. www.programming9.com
  • 5.
    Writing C Programs A programmer uses a text editor to create or modify files containing C code.  Code is also known as source code.  A file containing source code is called a source file.  After a C source file has been created, the programmer must invoke the C compiler before the program can be executed (run). www.programming9.com
  • 6.
    3 Stages ofCompilation Stage 1: Preprocessing  Performed by a program called the preprocessor  Modifies the source code (in RAM) according to preprocessor directives (preprocessor commands) embedded in the source code  Strips comments and white space from the code  The source code as stored on disk is not modified. www.programming9.com
  • 7.
    3 Stages ofCompilation (con’t) Stage 2: Compilation  Performed by a program called the compiler  Translates the preprocessor-modified source code into object code (machine code)  Checks for syntax errors and warnings  Saves the object code to a disk file, if instructed to do so (we will not do this). o If any compiler errors are received, no object code file will be generated. o An object code file will be generated if only warnings, not errors, are received. www.programming9.com
  • 8.
    3 Stages ofCompilation (con’t) Stage 3: Linking  Combines the program object code with other object code to produce the executable file.  The other object code can come from the Run-Time Library, other libraries, or object files that you have created.  Saves the executable code to a disk file. On the Linux system, that file is called a.out. o If any linker errors are received, no executable file will be generated. www.programming9.com
  • 9.
    Program Development Usinggcc Source File filename.c Program Object Code File filename.o Executable File a.out Preprocessor Modified Source Code in RAM Compiler Linker Other Object Code Files (if any) Editor www.programming9.com
  • 10.
    Why to useC ? www.programming9.com  Operating Systems  Language Compilers  Assemblers  Text Editors  Print Spoolers  Network Drivers  Modern Programs  Data Bases  Language Interpreters  Utilities
  • 11.
    References www.programming9.com  Kernighan, BrianW.;Dennis M. Ritchie (February 1978). The C Programming Language (1st ed.). Englewood Cliffs, NJ: Prentice Hall. ISBN 0-13-110163-3.