Programming in C 1: Overview of Computers and Programming
Programming in C 1: Overview of Computers and Programming
1: OVERVIEW OF COMPUTERS
AND PROGRAMMING
OUTLINE
Overview of Computers
Hardware
Software
Computer Languages
Software Development Method
Pseudo Code and Flowcharts
2
COMPUTERS
Computers receive input, store, process, and output
information.
Computercan deal with numbers, text, images, graphics,
and sound.
Computers are worthless without programming.
Programming Languages allow us to write programs that tell
the computer what to do and to provide a way to
communicate with computers.
Programs
are then converted to machine instructions so the
3
computer can understand it.
HARDWARE & SOFTWARE
Hardware is the equipment used to perform the necessary
computations.
Central Processing Unit (CPU), memory, disk storage,
6
MEMORY
Memory: a large collection of memory cells
0 One bit
Each Memory Cell has an address and a value
Memory Addresses
1
2 Byte = 8 bits
Bit: Binary digit = Either 0 or 1 3
.
. Byte at
.
Byte: Made up of 8 bits 16 65 address 16
17 value = 65
Memory Address: position of a memory cell 18
.
.
.
Memory Content: Value stored in memory
Every memory cell has content, whether we know it or not
Memory capacity
Kilobyte (KB) = 210 = 1024 Bytes; Megabyte (MB) = 220 Bytes > 106 Bytes
7
Gigabyte (GB) = 230 > 109 Bytes; Terabyte (TB) = 240 Bytes > 1012 Bytes
COMPUTER SOFTWARE
Operating
System - controls the interaction between
machine and user. Examples: Windows, Linux, etc.
Communicates with computer user.
11
FLOW OF INFORMATION DURING PROGRAM EXECUTION
Machine
Language
Program
Input
data
Output
Results
12
SOFTWARE DEVELOPMENT METHOD
3. Display kilometers
4. IMPLEMENTATION IN C LANGUAGE
16
MILES TO KILOMETERS CONT’D
5. Test
We need to test the previous program to make sure it works. To test
we run our program and enter different values and make sure the
output is correct.
6. Maintenance
Next time, your boss wants to add a new feature, so he wants you to
add support for converting different units.
17
PSEUDO CODE AND FLOWCHART
18
WHY USE PSEUDO CODE?
The benefit of pseudo code is that it enables the programmer to
concentrate on the algorithm without worrying about all the
syntactic details of a particular programming language.
In fact, you can write pseudo code without even knowing what
programming language you will use for the final implementation.
Pseudo code cannot be compiled or executed, and does not follow
syntax rules. It is simply an important step in producing the final
code.
Example:
Input Miles
Kilometers = Miles * 1.609
Output Kilometers 19
ANOTHER EXAMPLE OF PSEUDO CODE
Problem: Calculate your final grade for ICS 103
Specify the problem: Get different grades and then compute the
final grade.
Analyze the problem: We need to input grades for exams, labs,
quizzes and the percentage each part counts for. Then we need to
output the final grade.
Design
1. Get the grades: exams, quizzes, assignments, and labs.
2. Grade = 0.25 * Midterm Exam + 0.3 * Final Exam + 0.2 * Quizzes + 0.05 *
Assignments + 0.2 * Lab
3. Output the Grade
Implement and Test: Learn how to program in C, Write the
program, then Input some test values, calculate and check the final20
grade.
FLOWCHART
Flowchart uses boxes and arrows to show step by step execution of a
program.
Decision Document
21
EXAMPLE OF A FLOWCHART
Start
End
22