Introduction to Programming
Definition of Programming
Programming is the process of
writing instructions that a
computer can follow to perform a
specific task. These instructions
are written using programming
languages
What is a Program?
A program is a set of step-by-
step instructions written in a
programming language that tells
a computer what to do.
Example:
A calculator app is a program
that takes numbers and performs
operations like addition or
subtraction.
Importance of Programming
- Tells computers what to do.
- Automates tasks to save time
and reduce errors.
- Solves problems efficiently.
- Builds software, games,
websites, and apps.
- Encourages logical and critical
thinking.
Common Programming
Languages
- Visual Basic– beginner-friendly,
often used in schools.
- Python – easy to read and
understand.
- Java – used in apps and
enterprise software.
- C++ – used in system/software
development.
Types of Programming
Languages
1. Low-Level Languages – close
to machine code (e.g.,
Assembly).
2. High-Level Languages– easier
for humans to understand (e.g
VB, Python )
Types of Programming
Languages
Programming languages are
used to write instructions that a
computer can understand. They
are broadly categorized into:
1. Low-Level Programming
Languages
These are languages*close to
machine code (binary – 1s and
0s) and give direct control over
hardware.
a. Machine Language
- The only language directly
understood by computers.
- Written in binary code (0s and
1s).
- Very fast but hard for humans
to read or write.
b. Assembly Language
- Uses short codes (called
mnemonics) like
`MOV`, `ADD`, `SUB`.
- Each instruction corresponds to
a machine code instruction.
- Needs an assembler to convert
it to machine code.
Example:
MOV A, 5
ADD A, B
Advantages:
- Very fast
- Efficient memory use
Disadvantages:
- Hard to learn
- Not portable between
computers
2. High-Level Programming
Languages
These are more human-friendly
and easier to understand and
write. They require a compiler or
interpreter to translate code into
machine language.
Examples:
- Visual Basic (VB)
- Python
- Java
- C++
- Pascal
Features:
- Use English-like syntax
- Easier to debug and maintain
Basic Programming Concepts to
Learn
- Variables
- Data types
- Input/output
- Loops
- Conditions (if statements)
- Functions
Basic Programming Concepts
1. Variables
Definition:
Variables are containers used to
store data that can change
during program execution.
Example in Visual Basic:
vb
Dim age As Integer
age = 16
Key Points:
- Every variable has a name and
a data type.
- Values stored in variables can
be updated as the program runs.
2. Data Types
Definition:
Data types specify the kind of
data a variable can hold.
Common Data Types:
- Integer– whole numbers (e.g.,
10, -5)
- Double– decimal numbers (e.g.,
3.14)
- String – text (e.g., "Hello")
- Boolean – true or false
Example
vb
Dim name As String
Dim isPassed As Boolean
3. Input/Output (I/O)
Input:
Data received from the user or
another source.
Output:
Information shown to the user
(e.g., through the screen).
Examples:
vb
name = InputBox("Enter your
name:")
MsgBox("Hello, " & name)
Tools in Visual Basic:
- InputBox() – to take user input.
- MsgBox()– to display output.
4. Loops
Definition:
Loops allow you to repeat a
block of code multiple times.
Types of Loops:
- For Loop:Repeats a set number
of times.
- While Loop:Repeats while a
condition is true.
Example:
vb
For i = 1 To 5
MsgBox("Count: " & i)
Next i
5. Conditions (If Statements)
Definition:
Used to make decisions in a
program based on conditions.
Example:
vb
If age >= 18 Then
MsgBox("You are an adult.")
Else
MsgBox("You are underage.")
End If
Other Forms:
- `ElseIf`
- `Select Case` (for multiple
conditions)
6. Functions
Definition:
Functions are reusable blocks of
code that perform a specific task.
Advantages:
- Code reusability
- Easy to debug and maintain
- Cleaner code structure
Example:
vb
Function AddNumbers(a As
Integer, b As Integer) As Integer
Return a + b
End Function
Real-Life Analogy
Programming is like writing a
recipe. Each step must be clear
and in the correct order, or the
final product won’t turn out right.