0% found this document useful (0 votes)
2 views

chapter-1-theory-lecture-notes

The document provides lecture notes on the introduction to programming, covering essential topics such as hardware and software, how computers store data, and the program development process. It explains the roles of CPUs, memory, input and output devices, and the distinction between system and application software. Additionally, it introduces programming languages, graphical user interfaces, and the steps involved in creating a program.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

chapter-1-theory-lecture-notes

The document provides lecture notes on the introduction to programming, covering essential topics such as hardware and software, how computers store data, and the program development process. It explains the roles of CPUs, memory, input and output devices, and the distinction between system and application software. Additionally, it introduces programming languages, graphical user interfaces, and the steps involved in creating a program.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 33

lOMoARcPSD|33430560

Chapter 1 - Theory - lecture notes

Introduction to Programming (University of KwaZulu-Natal)

Scan to open on Studocu

Studocu is not sponsored or endorsed by any college or university


Downloaded by Silindokuhle Boyi ([email protected])
lOMoARcPSD|33430560

2/17/2023

Introduction to Computing and


Programming

Copyright © 2017 Pearson Education, Ltd.

Topics
• 1.1 Introduction
• 1.2 Hardware and Software
• 1.3 How Computers Store Data
• 1.4 How a Program Works
• 1.5 Graphical User Interfaces
• 1.6 Objects
• 1.7 The Program Development Process
• 1.8 Getting Started with the Visual Studio Environment

Copyright © 2017 Pearson Education, Ltd.

1
Downloaded by Silindokuhle Boyi ([email protected])
lOMoARcPSD|33430560

2/17/2023

What is a program?

Copyright © 2017 Pearson Education, Ltd.

1.1 Introduction
• A program is a set of instructions that a
computer follows to perform a task
– Programs are commonly referred to as software
– Without software, computers cannot do anything
• Programmers, or software developers, create
software
– They are people with the training and skills necessary
to design, create, and test programs

Copyright © 2017 Pearson Education, Ltd.

2
Downloaded by Silindokuhle Boyi ([email protected])
lOMoARcPSD|33430560

2/17/2023

Hardware and Software

Copyright © 2017 Pearson Education, Ltd.

1.2 Hardware and Software


• Hardware refers to all physical devices
– A computer consists of many pieces of hardware that
all work together
– Each piece of hardware does its own work
• A typical computer system contains:
– The CPU
– Main memory
– Secondary storage devices
– Input devices
– Output devices
Copyright © 2017 Pearson Education, Ltd.

3
Downloaded by Silindokuhle Boyi ([email protected])
lOMoARcPSD|33430560

2/17/2023

The CPU

Copyright © 2017 Pearson Education, Ltd.

The CPU
• The central processing unit is the part that
actually runs programs
– The most important part of a computer
– Today CPUs are microprocessor
– Commonly used CPU vendors are Intel and
AMD

Copyright © 2017 Pearson Education, Ltd.

4
Downloaded by Silindokuhle Boyi ([email protected])
lOMoARcPSD|33430560

2/17/2023

Main Memory

Copyright © 2017 Pearson Education, Ltd.

Main Memory
• The computer’s work area
• Where the computer loads instructions of
programs and data for processing
• Commonly known as RAM, random-access
memory
– Designed for CPUs to quickly access data stored at
any random location in the RAM
• They are a volatile type of memory
– When the computer is powered off, the contents in
RAM are erased
Copyright © 2017 Pearson Education, Ltd.

5
Downloaded by Silindokuhle Boyi ([email protected])
lOMoARcPSD|33430560

2/17/2023

Secondary Storage Devices

Copyright © 2017 Pearson Education, Ltd.

Secondary Storage Devices


• Devices that can hold data for long periods of
time, even when the power is off
– Where important data and system files are stored
– Most commonly used is the disk drive which stores
data by magnetically encoding it onto a circular disk
– Solid state drives have no moving parts, and
operate faster than a traditional disk drive.
– Optical devices such as DVD-ROMs and CD-ROMs
are also popular
– USB drives and SD memory cards are small
devices that plug into a port
Copyright © 2017 Pearson Education, Ltd.

6
Downloaded by Silindokuhle Boyi ([email protected])
lOMoARcPSD|33430560

2/17/2023

Input Devices

Copyright © 2017 Pearson Education, Ltd.

Input Devices
• Input is any data the computer collects
from people and devices
• Devices that collect the data and send
them to the computer are called input
devices
• Commonly used input devices are touch
screens, keyboards, mouses, scanners,
microphones, and digital cameras

Copyright © 2017 Pearson Education, Ltd.

7
Downloaded by Silindokuhle Boyi ([email protected])
lOMoARcPSD|33430560

2/17/2023

Output Devices

Copyright © 2017 Pearson Education, Ltd.

Output Devices
• Output is any data the computer produces
for people or devices
• The device that generates output for a
computer is called an output device
• Commonly used output devices are
screens, speakers, and printers

Copyright © 2017 Pearson Education, Ltd.

8
Downloaded by Silindokuhle Boyi ([email protected])
lOMoARcPSD|33430560

2/17/2023

Copyright © 2017 Pearson Education, Ltd.

Software

Copyright © 2017 Pearson Education, Ltd.

9
Downloaded by Silindokuhle Boyi ([email protected])
lOMoARcPSD|33430560

2/17/2023

Software
• Categorized mainly into system software and
application software
– System software are programs that control and
manage the basic operations of a computer.
Subcategories are:
• Operating systems
• Utility programs
• Software development tools
– Application software are programs that perform
special tasks

Copyright © 2017 Pearson Education, Ltd.

How Computers Store Data

Copyright © 2017 Pearson Education, Ltd.

10
Downloaded by Silindokuhle Boyi ([email protected])
lOMoARcPSD|33430560

2/17/2023

How Computers Store Data


• All data stored in a computer is converted to sequence of
0s and 1s; each sequence is called a bit
• A computer’s memory is divided into tiny storage
locations called bytes
– Eight bits make a byte
• Combinations of bits, 0s and 1s, are used to represent
characters. For example,
– The character ‘A’ is 65 in ASCII code, which is converted to
binary format 1000001
– When you press ‘A’, 1000001 will be stored in computer’s
memory

Copyright © 2017 Pearson Education, Ltd.

Copyright © 2017 Pearson Education, Ltd.

11
Downloaded by Silindokuhle Boyi ([email protected])
lOMoARcPSD|33430560

2/17/2023

Digital and Digital Data

Copyright © 2017 Pearson Education, Ltd.

Digital and Digital Data


• “Digital” refers to anything that can only
have two possible values
– Digital data is the data that is stored in binary.
– Digital devices are devices that work with
binary data
– Computers are digital devices

Copyright © 2017 Pearson Education, Ltd.

12
Downloaded by Silindokuhle Boyi ([email protected])
lOMoARcPSD|33430560

2/17/2023

How a Program Works

Copyright © 2017 Pearson Education, Ltd.

1.4 How a Program Works


• CPU reads instructions written in machine language
called instruction set
• A program will be copied into memory for CPU to
execute
• CPU uses the “fetch-decode-execute” cycle for
processing
– Fetch: Reads instructions from memory
– Decode: Decodes the instructions that were just read to
determine how to perform operations
– Execute: Actually performs the operations

Copyright © 2017 Pearson Education, Ltd.

13
Downloaded by Silindokuhle Boyi ([email protected])
lOMoARcPSD|33430560

2/17/2023

Programming Languages

Copyright © 2017 Pearson Education, Ltd.

Programming Languages
– Machine languages: sequences of 0s and 1s
– Assembly languages: use short words known
as “mnemonics” to write program
• Must be translated by assembler
• Still considered low-level languages
• add, mul, mov
– High-level languages: more human readable
languages that allow programmers to create
programs without knowing how CPU works.
• Modern languages are high-level
Copyright © 2017 Pearson Education, Ltd.

14
Downloaded by Silindokuhle Boyi ([email protected])
lOMoARcPSD|33430560

2/17/2023

Copyright © 2017 Pearson Education, Ltd.

Copyright © 2017 Pearson Education, Ltd.

15
Downloaded by Silindokuhle Boyi ([email protected])
lOMoARcPSD|33430560

2/17/2023

Keywords, Operators, and Syntax

Copyright © 2017 Pearson Education, Ltd.

Keywords, Operators, and Syntax


• High level languages use keywords that have
special meaning and cannot be used for any
purpose other than to write programs
• Operators are keywords that represent special
program functions such as addition, subtraction, and
multiplication
• Syntax is a set of rules that must be strictly followed
to write computer-understandable instructions
– Syntax error is a mistake or violation of these rules
• Each instruction in a program is called a statement

Copyright © 2017 Pearson Education, Ltd.

16
Downloaded by Silindokuhle Boyi ([email protected])
lOMoARcPSD|33430560

2/17/2023

Compilers and Interpreters

Copyright © 2017 Pearson Education, Ltd.

Compilers and Interpreters


• A compiler translates a high-level language
program to a separate machine program for
CPU to read and execute
– Source code: the statements a programmer writes in
a high-level language
– Compilation: translates a text-based source code to
binary codes
• Interpreter reads, translates, and executes the
instructions of a high-level language program
– Examples are PHP, Perl, Python

Copyright © 2017 Pearson Education, Ltd.

17
Downloaded by Silindokuhle Boyi ([email protected])
lOMoARcPSD|33430560

2/17/2023

Copyright © 2017 Pearson Education, Ltd.

Graphical User Interface

Copyright © 2017 Pearson Education, Ltd.

18
Downloaded by Silindokuhle Boyi ([email protected])
lOMoARcPSD|33430560

2/17/2023

1.5 Graphical User Interface


• User interfaces allow users to interact with the
computer. Categories are:
– Command line interface (aka console interface)
– Graphical user interface (GUI)- now the most
commonly used

Copyright © 2017 Pearson Education, Ltd.

Event-Driven GUI Programs


• In a text based environment, such as
command line interface, programs
determine the order in which things
happen.
• In a GUI environment, the user determine
the order in which things happen.

Copyright © 2017 Pearson Education, Ltd.

19
Downloaded by Silindokuhle Boyi ([email protected])
lOMoARcPSD|33430560

2/17/2023

Objects

Copyright © 2017 Pearson Education, Ltd.

1.6 Objects
• Most programming languages use object-oriented
programming in which a program component is called an
“object”
• Program objects have properties (or fields) and methods
– Properties – data stored in an object
– Methods – the operations an object can perform

Copyright © 2017 Pearson Education, Ltd.

20
Downloaded by Silindokuhle Boyi ([email protected])
lOMoARcPSD|33430560

2/17/2023

Controls

Copyright © 2017 Pearson Education, Ltd.

Controls
• Objects that are visible in a program GUI are
known as controls
– Commonly used controls are Labels, Buttons, and
TextBoxes
– They enhance the functionality of your programs
• There are invisible objects in a GUI such as
Timers, and OpenFileDialog

Copyright © 2017 Pearson Education, Ltd.

21
Downloaded by Silindokuhle Boyi ([email protected])
lOMoARcPSD|33430560

2/17/2023

The .NET Framework

Copyright © 2017 Pearson Education, Ltd.

The .NET Framework


• The .NET Framework is a collection of classes
and other codes that can be used to create
programs for Windows operating system
• C# is a language supported by the .NET
Framework
• Controls are defined by specialized classes
provided by the .NET Framework
• You can also write your own class to perform a
special task

Copyright © 2017 Pearson Education, Ltd.

22
Downloaded by Silindokuhle Boyi ([email protected])
lOMoARcPSD|33430560

2/17/2023

The Program Development


Process

Copyright © 2017 Pearson Education, Ltd.

1.7 The Program Development


Process
• The process of creating a program is known as
the programming development cycle
• It has six phases:
– Understand the program’s purpose
– Design the GUI
– Design the program’s logic
– Write the code
– Correct syntax errors
– Test the program and correct logic errors

Copyright © 2017 Pearson Education, Ltd.

23
Downloaded by Silindokuhle Boyi ([email protected])
lOMoARcPSD|33430560

2/17/2023

Algorithm, Pseudocode, Flowchart

Copyright © 2017 Pearson Education, Ltd.

Algorithm, Pseudocode, Flowchart


• An algorithm is a set of well-defined,
logical steps that must be taken to perform
a task
• An algorithm that is written out in plain
English is called pseudocode
• A flowchart is a diagram that graphically
depicts the steps of an algorithm

Copyright © 2017 Pearson Education, Ltd.

24
Downloaded by Silindokuhle Boyi ([email protected])
lOMoARcPSD|33430560

2/17/2023

Pseudocode example
If student's grade is greater than or equal to
60

Print "passed"
else
Print "failed"

Copyright © 2017 Pearson Education, Ltd.

Flowchart example

Copyright © 2017 Pearson Education, Ltd.

25
Downloaded by Silindokuhle Boyi ([email protected])
lOMoARcPSD|33430560

2/17/2023

1.8 Getting Started with the Visual


Studio Environment
• Visual Studio 2012 is a professional integrated
development environment (IDE)
• The Visual Studio Environment includes:
– Designer Window
– Solution Explorer Window
– Properties Window

Copyright © 2017 Pearson Education, Ltd.

1.8 Getting Started with the Visual


Studio Environment

The Designer

Copyright © 2017 Pearson Education, Ltd.

26
Downloaded by Silindokuhle Boyi ([email protected])
lOMoARcPSD|33430560

2/17/2023

1.8 Getting Started with the Visual


Studio Environment

Solution Explorer

Copyright © 2017 Pearson Education, Ltd.

1.8 Getting Started with the Visual


Studio Environment

Properties Window

Copyright © 2017 Pearson Education, Ltd.

27
Downloaded by Silindokuhle Boyi ([email protected])
lOMoARcPSD|33430560

2/17/2023

1.8 Getting Started with the Visual


Studio Environment
• Auto Hide allows a window to display only as a
tab of the edges

Pushpin icon means it supports Auto Hide

Copyright © 2017 Pearson Education, Ltd.

Menu Bar and Standard Toolbar


• Menu bar provides menus such as File,
Edit, View, Project, etc.

• Standard toolbar contains buttons that


execute frequently used commands

Copyright © 2017 Pearson Education, Ltd.

28
Downloaded by Silindokuhle Boyi ([email protected])
lOMoARcPSD|33430560

2/17/2023

The Toolbox
• Toolbox is a window for selecting controls to use in an
application
– Typically appears on the left side of Visual Studio environment
– Usually in Auto Hide mode

Toolbox tab

Copyright © 2017 Pearson Education, Ltd.

The Toolbox
• Toolbox is a window for selecting controls to use in an
application
– Divided into sections such as “All Windows Forms” and
“Common Controls”

Copyright © 2017 Pearson Education, Ltd.

29
Downloaded by Silindokuhle Boyi ([email protected])
lOMoARcPSD|33430560

2/17/2023

Tooltips
• A Tooltip is a small box that pops up when you hover the
mouse pointer over an item on the toolbar or toolbox.

Tooltip

Copyright © 2017 Pearson Education, Ltd.

Docked and Floating Windows


• When a window such as Solution Explorer is
docked, it is attached to one of the edges of the
Visual Studio environment
• When a window is floating, you can click and
drag it around the screen
– A window cannot float if it is in Auto Hide mode
• Right click a window’s title bar and select Float
or Dock to change between them

Copyright © 2017 Pearson Education, Ltd.

30
Downloaded by Silindokuhle Boyi ([email protected])
lOMoARcPSD|33430560

2/17/2023

Projects and Solutions


• Each Visual Studio application (including Visual
C#) you will create is a project
– A project contains several files.
– Typically they are Form1.cs, Program.cs, etc.
• A solution is a container that can hold one or
more Visual Studio (including Visual C#) projects
– Each project, however, is saved in its own solution
Solution Project
Files belonging to the project

Copyright © 2017 Pearson Education, Ltd.

Specifying the Project Name


• You can specify the project name the first
time you save the project.

Copyright © 2017 Pearson Education, Ltd.

31
Downloaded by Silindokuhle Boyi ([email protected])
lOMoARcPSD|33430560

2/17/2023

Displaying the Designer


• Sometimes when you open an existing project, the
project’s form will not be automatically displayed in the
Designer
• You should:
– Right click Form1.cs in
the Solution Explorer
– Click View Designer in
the pop-up menu

Copyright © 2017 Pearson Education, Ltd.

32
Downloaded by Silindokuhle Boyi ([email protected])

You might also like