Fop Lec1a 13sep13

Embed Size (px)

Citation preview

  • 8/11/2019 Fop Lec1a 13sep13

    1/19

    Fundamentals of Programming

    (FOP)

    Instructor: Adeela [email protected], [email protected]

    Military College of Signals, Rawalpindi

    Lecture 1A

    Basics of C++ Programming

    13 September 2013

  • 8/11/2019 Fop Lec1a 13sep13

    2/19

  • 8/11/2019 Fop Lec1a 13sep13

    3/19

    What is a Computer?

    A computer is an electronic device that can followinstructionsto

    Accept input (data)

    Process that input

    Produce output (information)

    Data is raw, unorganized factsthat need to be processed. Datacan be something simple andseemingly random and useless

    until it is organized

    When data is processed,organized, structured orpresented in a given context soas to make it useful, it is called

    Information

    Each student's test score The class' average score or the

    school's average score

    For Example For Example

  • 8/11/2019 Fop Lec1a 13sep13

    4/19

    What is a Computer?

    A computer is an electronic device, operatingunder the control of instructions (software) stored

    in its own memory unit, that can accept data

    (input), manipulate data (process), and produce

    information (output) from the processing Generally, the term is used to describe a collection

    of devices that function together as a system

  • 8/11/2019 Fop Lec1a 13sep13

    5/19

    What does a Computer do?

    Computers perform four general operations, which

    make up the information processing cycle

    Input Process

    Output

    Storage

    http://www.buzzle.com/articles/information-processing-cycle.html

  • 8/11/2019 Fop Lec1a 13sep13

    6/19

    Devices that Comprise a Computer

    System

    Printer(output)

    Monitor(output)

    Speaker(output)

    Scanner(input)

    Mouse(input)

    Keyboard(input)

    System Unit

    (processor, memory)

    Storage Devices

    (CD-RW, Floppy,Hard disk etc)

  • 8/11/2019 Fop Lec1a 13sep13

    7/19

  • 8/11/2019 Fop Lec1a 13sep13

    8/19

  • 8/11/2019 Fop Lec1a 13sep13

    9/19

    Computer Programs

    The ProgrammerThe Computer

    Programmer writes aset of instructions

    for Computer

    This set is called aComputer Program

  • 8/11/2019 Fop Lec1a 13sep13

    10/19

    Programming Languages

    Programmers write these instructions in different

    programming languages.

    Programming Languages

    Requiring intermediate translationsteps

    Directly understandable byComputer

    Machine Languages Assembly Languages High Level Languages

  • 8/11/2019 Fop Lec1a 13sep13

    11/19

    Programming Languages

    Machine Languages Strings of 0s and 1s

    Directly understandable by computer

    Defined by hardware of the machine

    Hard for human beings to learn, error prone

    Slow programming

    Assembly Languages

    English like abbreviations

    Not directly understandable by computer, hence required translator

    programs called Assemblers

    Relatively easier for human beings to learn

    Slightly faster programming

  • 8/11/2019 Fop Lec1a 13sep13

    12/19

    Programming Languages

    High Level Languages Developed for fast and speedy programming

    Not directly understandable by computer, hence required translator

    programs called Compilers

    Not dependant on hardware of the machine (mostly) Easy to learn, less chances of error

    Fast programming

    Interpreters are another important category of translator programs

  • 8/11/2019 Fop Lec1a 13sep13

    13/19

    Why C++

    C is a language designed by and for programmers

    C++ is an expanded and enhanced version of C

    Programming Language

    It is the language of choice for professional programmersworldwide

    Once mastered, C++ will give you complete control over

    the computer C++ is, above all, the most powerful programming

    language ever invented!!!

  • 8/11/2019 Fop Lec1a 13sep13

    14/19

    Compiler

    C++ Program

    int main() {

    int i=1;

    . . .

    Machine

    Language

    Program

    01001001

    10010100

    C++ Compiler

    (e.g. g++)

    Created with text editor or

    development environment

  • 8/11/2019 Fop Lec1a 13sep13

    15/19

  • 8/11/2019 Fop Lec1a 13sep13

    16/19

    The C++ Standard Library

    C++ programs consist of pieces/modules called classes andfunctions

    A programmer can create his own functions

    Advantage: the programmer knows exactly how it works

    Disadvantage: time consuming

    Programmers will often use the C++ library functions

    Use these as building blocks

    Avoid re-inventing the wheel

    If a pre-made function exists, generally best to use it rather than writeyour own

    Library functions carefully written, efficient, and portable

  • 8/11/2019 Fop Lec1a 13sep13

    17/19

  • 8/11/2019 Fop Lec1a 13sep13

    18/19

  • 8/11/2019 Fop Lec1a 13sep13

    19/19

    Study Material

    Text Book : Chapter 1