0% found this document useful (0 votes)
7 views11 pages

Module # 2 - Evaluating Expressions

The document provides an overview of evaluating expressions in computer programming, focusing on the distinction between constants and variables, as well as the rules for naming identifiers. It explains various types of operators, including mathematical, relational, logical, and bitwise operators, along with examples of their usage. Additionally, it covers different data types used in programming and their syntax.
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)
7 views11 pages

Module # 2 - Evaluating Expressions

The document provides an overview of evaluating expressions in computer programming, focusing on the distinction between constants and variables, as well as the rules for naming identifiers. It explains various types of operators, including mathematical, relational, logical, and bitwise operators, along with examples of their usage. Additionally, it covers different data types used in programming and their syntax.
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/ 11

EVALUATING EXPRESSIONS

AUDREY LYLE D. DIEGO


ES113-18 – Computer Programming
Learning Outcomes
Differentiate CONSTANTS Know the proper ways in
from VARIABLES naming identifiers

Understand how Evaluate expressions based


expressions are evaluated on the implemented
by the computer operator/s

Understand the different


data types used in
programming
• Constant
• Permanent storage
• pi = 3.14

• Variable
Data • Temporary storage of data
• Identifiers – name of variables

Storage • Rules in naming identifiers


• Not more than 132 characters
• Alphanumeric, starts with a
letter or underscore
• Not a keyword (C++ cout, cin)
• No spaces
• Case sensitive/ unique
cout = 10
5neu
Invalid
Invalid

Neu5 Ne#u
Valid Invalid

Examples
neu = 5 NeU = 6
•pri nt the value of NEU
_neu nul l
Valid •pri nt the value of neu
5
•pri nt the value of Neu
nul l

xy – 1 variable x,y, xy - 3 variables


Operands

• variables or constants that we


process

Operators

Expressions • used to evaluate and process


operands
• Z = x +y
• Infix Notation x
+y
• Prefix Notation + xy
• Postfix Notation
xy+
Mathematical/ Arithmetic

• () * /+ -% % - modulus/ modulo - remainder

Relational

• - >, <, >=, <=, ==, != 5 > 3 = True; 5 > 5 = False, 5>=5 = True,
5 ==5 = True, 5!=3 = True

Logical, Bitwise Operators

• && = AND || = OR ! = NOT

Types of Increment ++

Operators Decrement --

Assignment

•= x=5 if (x ==5)

Combined x = 2; y = 3

• x+=y x = x+y x =5
• x-= y x = x-y x = -1
• x*=y x = x*y x =6
• x/=y x = x/y x =1
Z = 5 /2 2.5
=2
Examples
X=5%2
=1
True if ALL statements are
&& TRUE

Logical || True if at least ONE or ALL of


the statements are TRUE
Operators

! True if the input is False


Examples

X = 5; Y=2

A = ((X > 5) && (Y==2))


F && T
A = False
B = (X++ > = (10/2)) || (Y<0)
(6 >=5) || F
T || F
B = True
C = !B
= False
It tells what type of data a
variable can store

char - character

Data Types int - integer; whole number

float/ double - fraction/ decimal

Syntax: <data type> _


<identifier>;
Examples
char name[10]; string [10] - index
int xyz;
float a; double a;
name = Paulo cout<<name; Paulo
xyz = 3.5 cout<<xyz; 3
a = 3.5 cout<<a; 3.5

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy