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

Lec 1 - Introduction Basic Symbols and Variables

This document summarizes an introductory lecture on programming basics. It introduces computer system components like input, process, output. It describes the central processing unit and its parts. It defines key programming concepts like syntax, variables, and data types. The lecture explains how programs provide instructions to computers and highlights guidelines for developing programs.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views

Lec 1 - Introduction Basic Symbols and Variables

This document summarizes an introductory lecture on programming basics. It introduces computer system components like input, process, output. It describes the central processing unit and its parts. It defines key programming concepts like syntax, variables, and data types. The lecture explains how programs provide instructions to computers and highlights guidelines for developing programs.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 20

Introduction, Basic Symbols and Variables

Lecture 1
PROGRAMMING 1

Engr. Jennelyn P. Cabale

1
Tasks

Pre-Task While Task Post-Task

• NA • Lecture • Exercises
Presentation

Engr. Jen Perez-Cabale Lecture 1 - INTRODUCTION, BASIC SYMBOLS AND VARIABLE 2


Objectives Identify and explain the
different parts of the
central processing unit
Define syntax,
computer program,
Differentiate codes and variables
software from
hardware
Identify and explain the components
different computer
system components
Convert mathematical
expressions to
computer expressions

Identify different
arithmetic and relational
operators used in
Differentiate programming
common data types
Differentiate the
types of variables

Engr. Jen Perez-Cabale Lecture 1 - INTRODUCTION, BASIC SYMBOLS AND VARIABLE 3


Computer System Components

Engr. Jen Perez-Cabale Lecture 1 - INTRODUCTION, BASIC SYMBOLS AND VARIABLE 4


Input –Process-Output

INPUT OUTPUT
PROCESS

FEEDBACK

Components of a Computer System

Engr. Jen Perez-Cabale Lecture 1 - INTRODUCTION, BASIC SYMBOLS AND VARIABLE 5


The BluePrint

Serves as the basis of


how a computer
functions, and how data
are processed inside the
computer.

Engr. Jen Perez-Cabale Lecture 1 - INTRODUCTION, BASIC SYMBOLS AND VARIABLE 6


Central Processing Unit Components

Control Unit Register Arithmetic and


(CU) • a temporary Logic Unit (ALU)
• the command storage microchip • chief of operations
center of the that holds data of the computer.
processor during processing • mathematical
computations
• logical operations

Lecture 1 - INTRODUCTION, BASIC SYMBOLS AND VARIABLE 7


Engr. Jen Perez-Cabale
Behind the Scene in Action
Computer
• electronic device that can accept, process, and store
vast amount of data to produce useful information.
Syntax
• set of rules that govern a programming language.

Compiler
• transform the code into a machine language.

Engr. Jen Perez-Cabale Lecture 1 - INTRODUCTION, BASIC SYMBOLS AND VARIABLE 8


Lifeblood of a Computer System

• set of logical instructions


given to a computer for
data processing that is
Computer interpreted by a compiler
program or to produce useful
information
code

Engr. Jen Perez-Cabale Lecture 1 - INTRODUCTION, BASIC SYMBOLS AND VARIABLE 9


▪ Guide questions in planning and developing a program will be useful:

1
• What is the problem?

• What is the desired output? ACTIVITY:


2
Cite an
3
• What are the available data? analogy
using the
4
• What output information or data is needed? guide
above.
5
• When is the output needed?

6
• What processing is needed to produce the output

7
• Where should the output go?

Engr. Jen Perez-Cabale Lecture 1 - INTRODUCTION, BASIC SYMBOLS AND VARIABLE 10


Variables
Hungarian
Variable Data type
Notation
primary storage location that specifies a variable with both
can hold different numeric or the data type and its
alphanumeric values description

type of the data being


processed in the program
the first three characters
memory space allocated by a
specify the data type and the
computer user for processing
remaining characters are the
and storing data.
description of the variable.

Engr. Jen Perez-Cabale Lecture 1 - INTRODUCTION, BASIC SYMBOLS AND VARIABLE 11


DATA TYPE DESCRIPTION EXAMPLE

10 335 1590 54765 1


Integer Whole number
34000

Integer with decimal 3.1416 0.12 1.01 12.12


Float or Double
numbers 99.99 0.04

Alphabets and special J W A * & ? g t h


Character
characters + ) |

Sum age int_1 a_total


String Combination of characters
grand_total

Reply of the compiler in the


Values are eitehr 1 for YES
Boolean program that is performed
or 0 for NO
behind the scene.

Engr. Jen Perez-Cabale Lecture 1 - INTRODUCTION, BASIC SYMBOLS AND VARIABLE 12


VARIABLE NAME DATA TYPE DESCRIPTION
IntSum Integer Sum
DblTax Double Tax
FltRate Float Rate
ChrReply Character Reply
StrLname String Lname
BooAns Booelan Ans

Engr. Jen Perez-Cabale Lecture 1 - INTRODUCTION, BASIC SYMBOLS AND VARIABLE 13


Variable’s Name Characteristics
combinations the length of
of variable name
must be Example:
alphanumeric can have 256
descriptive and
characters can characters, the class_size
significant to
be used as a lesser the
the data, Int1
variable name number of
problem and
provided it characters the l_name
its solution
starts with an more efficient
alphabet the program is.

Engr. Jen Perez-Cabale Lecture 1 - INTRODUCTION, BASIC SYMBOLS AND VARIABLE 14


Computer Operators: Processing Data
OPERATION SYMBOL EXAMPLE EXPLANATION
Multiply the value of variable A to
Multiplication * A*B
the value of variable B
Divide the value of variable X by
Division / X/Y
the value of variable Y.
Add the value of variable int1to the
Addition + int1 + int2
value of variable int2.
Subtract the value of variable B
Subtraction - A-B
from the value of variable A.
Multiply the value of variable C
Exponentiation ^ C^2
twice

Engr. Jen Perez-Cabale Lecture 1 - INTRODUCTION, BASIC SYMBOLS AND VARIABLE 15


MATHEMATICAL
COMPUTER EXPRESSION
EXPRESSION

3xy 3*x*y

x2 + y2 (x * x) + (y * y) or x^2 + y^2

(3*x) / (y*y*y) or (3*x) / (y^3)

[(a*a) + (b*b)] / (c*d) or (a^2 + b^2) / (c*d)

Engr. Jen Perez-Cabale Lecture 1 - INTRODUCTION, BASIC SYMBOLS AND VARIABLE 16


Relational Operators
SYMBO
OPERATION EXAMPLE EXPLANATION
L
The value of variable A is greater than the
Greater than > A>B
value of variable B.
The value of variable X is less than the
Less than < X<Y
value of the variable Y.
The value of variable int1 is equal to the
Equal to == int1==int2
value of variable int2.
The value of variable net is not equal to the
Not equal to <> net <> gross
value of the variable gross.
Greater than or equal The value of variable pay1 is greater than
>= pay1 >= pay2
to or equal to the value of variable pay2.
The value of variable age1 is less than or
Less than or equal to <= age1 <= age2
equal to the value of variable age2.

Engr. Jen Perez-Cabale Lecture 1 - INTRODUCTION, BASIC SYMBOLS AND VARIABLE 17


Types of Variable

Destructive Constructive
variable variable
Variables that destroy or
change its value after
processing.
Variables that maintains its
value after processing.
This type of variable is
normally the temporary
storage of data during
processing.

Engr. Jen Perez-Cabale Lecture 1 - INTRODUCTION, BASIC SYMBOLS AND VARIABLE 18


Example
▪ What will happen if we have an instruction A=B? What is now the value
of A after processing the instruction? What is the value of B? And who
gets what data?

5
510 === 10 10
AAA BB
B
After processing the instruction, the value of variable
During processing, variable A gets the value of variable B. A
Theseisare
nowtheequivalent
original values
to theofvalue
the variables beforeB.processing.
of the variable

Engr. Jen Perez-Cabale Lecture 1 - INTRODUCTION, BASIC SYMBOLS AND VARIABLE 19


THE END

Engr. Jen Perez-Cabale Lecture 1 - INTRODUCTION, BASIC SYMBOLS AND VARIABLE 21

You might also like