The C Language - PowerPoint PPT Presentation

1 / 22
About This Presentation
Title:

The C Language

Description:

Chapter 1 The C++ Language – PowerPoint PPT presentation

Number of Views:23
Avg rating:3.0/5.0
Slides: 23
Provided by: pvb3
Learn more at: https://www.pvbears.org
Category:

less

Transcript and Presenter's Notes

Title: The C Language


1
Chapter 1
  • The C Language

2
Objectives
  • Describe various types of programs
  • Describe the role of the operating system
  • Describe how a computer gets instructions
  • Describe the role of the programming language,
    high- and low-level languages, interpreters, and
    compilers
  • Explain the structure of a C program

3
What is a computer program?
  • Computers are just machines and must follow
    directions.
  • Directions are grouped into logical sequences to
    create programs.
  • Programs that perform specific tasks such as word
    processing are called application programs.
  • When a computer is first turned on, it must
    follow the instructions embedded in ROM.

4
Operating Systems
  • The operating system takes charge of fundamental
    system operations including
  • Managing hardware
  • Maintaining file systems
  • Controlling input and output
  • Loading and executing programs

5
The Computers Language
  • The microprocessor is the device that actually
    processes the instructions given to the computer.
  • Each microprocessor has its own instruction set
    that it can understand.
  • The instructions provided to the microprocessor
    must be in machine language.
  • Machine language is a combination of circuits
    that can be represented with the binary number
    system.

6
Introduction to Programming Languages
  • Programming languages can be understood by people
    and computers.
  • Each language has its own set of rules and
    vocabulary.
  • Some are very much like English, while others are
    not.

7
Assembly Language
  • Uses numbers and letters to represent machine
    language instructions.
  • An assembler is needed to change the programmers
    code into machine language.
  • Examples of statements might look like the
    following
  • PUSH BP
  • MOV BP, SP
  • MOV SI, 0002

8
Low Level Languages
  • It is necessary for the programmer to know the
    instruction set of the microprocessor.
  • Programs are specific to a microprocessor.
  • Low level programs take up less memory.
  • You can do anything that the hardware will allow.

9
High-level Languages
  • One command may represent many microprocessor
    instructions.
  • You can write programs more quickly.
  • Instructions are usually more easy to read.
  • Easier to move between computers.

10
Examples of Languages
  • High-level
  • C
  • Java
  • Basic
  • Pascal
  • Visual Basic
  • Low-level
  • Machine language
  • Assembly language

11
Interpreters
  • Translate the source code of a high level
    language into machine language code known as
    object code.
  • Each instruction is interpreted as it is needed.
  • The interpreter must be loaded into memory first.
  • Object code is not saved.

12
Compilers
  • Also translate high level source into object
    code.
  • Makes the translation once and saves an object
    file.
  • The object file is combined with other machine
    language by the linker.
  • The linker generates the executable file.

13
C Program Structure
  • C has some major elements
  • Comments
  • Compiler directives
  • Main function
  • Braces
  • Statements

14
Comments
  • Comments are ignored by the compiler.
  • They are used to explain the purpose of the
    program, explain the source code, identify the
    parts of the program or store the names of the
    programmers.
  • Comments begin with a double forward slash (//).

15
Compiler Directives
  • Instructions to the compiler, not really part of
    the C language.
  • A common directive is the include directive
    which inserts other prewritten code into your
    program.
  • Includes are usually used to add additional
    functionality such as input/output to your
    program.

16
Main function
  • A function is a block of code that carries out a
    specific task.
  • Programs are usually divided into many functions,
    but the main function always runs first.
  • Functions are typically called from other parts
    of the program and they might return a value.

17
Braces
  • Braces are used to mark the beginning and end of
    a block of code.
  • Aligning the indention of opening and closing
    braces can make it easier to quickly identify
    blocks of code.

18
Statements
  • Statements are instructions that make the program
    work.
  • Each statement must end with a semicolon.
  • Directives and function declarations do not end
    with semicolons.
  • C is case sensitive so capitalization in
    statements does matter.

19
From source code to finished product
  • Type source code into text editor.
  • Compile the program into object code.
  • Link the object code with other machine language
    to generate an executable file.
  • The executable file can be run.

20
Summary
  • Computers follow instructions called programs.
  • Application programs perform specific tasks.
  • Operating systems manage fundamental computer
    activities.
  • The microprocessor processes each instruction.

21
Summary
  • An interpreter or compiler must translate high
    level languages into machine language.
  • Experience will teach you what language is
    appropriate for a specific task.
  • Comments are ignored by the compiler.
  • Directives are commands for the compiler.

22
Summary
  • All C programs have a main function. The main
    function is where the program begins running.
  • Braces mark the beginning and end of blocks of
    code.
  • Statements are the lines of code the computer
    executes.
  • Each statement ends with a semicolon.
  • C is case sensitive and it ignores extra space.
Write a Comment
User Comments (0)
About PowerShow.com