Anda di halaman 1dari 27

Course Objectives

At the end of this course, students will be able to:


CLO 1: Explain basic C++ programs using concepts of
constants, variables and arithmetic expressions. (Level C-2)
CLO 2: Classify decision (if-else) and repetition (loops)
statements. (Level C-2)
CLO 3: Apply the concepts of functions in C++ programs.
(Level C-3)
CLO 4: Write programs using one
dimensional/multidimensional arrays (Level C-3)
CLO 5: Demonstrate the working of pointers and
structures. (Level C-3)
CLO 6: Examine file handling techniques. (Level C-3)
Grading Policy

Quizzes & Assignments 25


Mid Term 25
Final exam 50
Assessments
All Quizzes/Assignment Modules will count towards
sessional marks
No best of option is available
Mid-term exam will be conducted in WEEK 8.
Final exam will be of 120 minutes duration.
80% attendance is mandatory.
Lecture Outline

Anatomy of a computer
Programming languages
Syntax of C++ program
Errors in programming
Algorithms using Pseudocodes/ Flowcharts
THE ANATOMY OF A COMPUTER

Hardware
CPU (central processing unit)
Storage
Peripheral Devices

Software
System Software
Application Software
CPU (CENTRAL PROCESSING UNIT)
heart of the computer
executes one operation at a time
performs program control and data processing
arithmetic operations such as addition,
subtraction, multiplication, and division
STORAGE
Primary memory - memory chips
Random access memory (RAM) (read-write
memory)
Read-only memory (ROM)

Secondary storage devices


disk drives
CDs
PERIPHERAL DEVICES

Output Devices
Display screen
Speakers
Printers

Input Devices
Keyboard
Mouse
SCHEMATIC DESIGN
PROGRAMMING

A precise sequence of instructions to


solve a particular problem

Computer programming is the act of designing and


implementing computer programs.
PROGRAMMING LANGUAGES

Machine Code
Binary Format
Processor Dependent

Higher Level Programming Languages


Independent of processor and hardware type
Needs compiler
C++
THE EVOLUTION OF C++
C (1972)
C++ (1985)
ANSI Standard C++ (1998)
ANSI Standard C++ [revised] (2003)
The present C++
a general-purpose language that is in widespread use
for systems and embedded
the most commonly used language for developing
system software such as databases and operating
systems
PROGRAMMING ENVIRONMENT
An IDE (integrated development environment) is
used for developing C++ programs.
The compiler translates C++ programs into machine
code.

The linker combines machine code with library code


into an executable program.
STEPS OF WRITING A C++ PROGRAM

Define a problem
Design a solution
Translate into a C++ program
Test the C++ program
Debug incase of errors
ANALYZING YOUR FIRST PROGRAM
ERRORS IN PROGRAMMING
Syntax or compile-time error
Run time error
Software Development Process

For each problem the programmer


goes through these steps:
PROGRAMMING AS A PROBLEM SOLVING
PROCESS
Define and analyze the problem.
What is the input & output?
What constraints must be satisfied?
What information is essential?

Develop an algorithm.
What steps must be done?

Implement a program (steps in sequence)


Compile, test, and debug the program.
Document and maintain the program.
DESIGN A SOLUTION

Sequence of Steps /Instructions

Pseudo-code: Expressed in informal, everyday


language

Flowchart: Solution expressed in diagram


PSEUDOCODE

The method described in pseudocode must be


Unambiguous
There are precise instructions for what
to do at each step
and where to go next.
Executable
Each step can be carried out in practice.
Terminating
It will eventually come to an end.
EXAMPLE

You put 10000$ into a bank account that earns 5%


interest/year. How many years does it take for the
account balance to double the original?
SOLUTION

Start with year value 0, interest 0 and balance of


10000$
Repeat the following steps until balance is 20000$
Add 1 to year value
Calculate interest as (balance x 0.05)
Add interest to balance
Final year is the answer
WHAT MAKES A GOOD PROGRAM?

Correctness
Meets the problem requirements
Produces correct results
Easy to read and understand
Easy to modify
Easy to debug
Efficient
Fast
Requires less memory
MOTIVATION

Program the computer in applications such as


the following:

Program a simple calculator

Program simple computer games

Program a small inventory system

Anda mungkin juga menyukai