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

2. Data Types Variables Operators

Data types

Uploaded by

arumiyeso
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views

2. Data Types Variables Operators

Data types

Uploaded by

arumiyeso
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 8

Mindoro State University

College of Computer Studies

DATA TYPES, VARIABLES,


OPERATORS

Prepared by:

LEE-MAR
Instructor I
M. ARCON
E-mail Address: [email protected]
Mobile Number: +639511177784

Bachelor
ITC 121 : COMPUTER PROGRAMMING 2 of Science in
College of
College of
Computer
Computer Learning Objectives
Click to edit
Studies
Studies Master title style

At the end of the lesson, the learners should be able to:

1. defined what are the different operators that can be


used in programming
2. explained the importance of precedence
3. gained mastery of using operators and precedence

ITC 121 : COMPUTER PROGRAMMING 2 TOPIC: DATA TYPES, VARIABLES, OPERATORS


College of
College of
Computer
Computer DATA TYPES
Click to edit
Studies
Studies Master title style
Data Description Size (bits) Range Sample usage
type
Whole numbers int count;
int 32 -231 through 231
(integers) count = 42;
Whole numbers long wait;
long 64 -263 through 263
(bigger range) wait = 42L;
Floating-point -3.4x1038 through 3.4x1038 float away;
float 32
numbers (up to 7 significant digits) away = 0.42F;
Double-precision double trouble;
(more accurate) ±5.0x10324 through ±1.7x10308 trouble = 0.42;
double 64
floating-point (up to 15 significant digits)
numbers
Sequence of 16 bits per string vest;
string Not Applicable
characters character vest = "forty two"
char grill;
char Single character 16 A Single Character
grill = 'x';
bool teeth;
bool Boolean 8 true or false
teeth = false;

ITC 121 : COMPUTER PROGRAMMING 2 TOPIC: DATA TYPES, VARIABLES, OPERATORS


College of
College of
Computer
Computer VARIABLES
Click to edit
Studies
Studies Master title style

A variable is a storage location that holds a value.


You can think of a variable as a box in the computer’s
memory that holds temporary information.

Variable naming rules:


 Must not begin from a number
 Can’t contain any special character except

underscore(_).
ITC 121 : COMPUTER PROGRAMMING 2 TOPIC: DATA TYPES, VARIABLES, OPERATORS
College of
College of
Computer
Computer VARIABLES
Click to edit
Studies
Studies Master title style
 Can begin with a letter (a-z, A-Z) or underscore(_)
 Variable names are case-sensitive
 It cannot be a keyword or a reserve word in C#.
Example of keywords:
 bool
 class
 while
 string
 It should be descriptive and meaningful.
 Whitespace is not allowed.
ITC 121 : COMPUTER PROGRAMMING 2 TOPIC: DATA TYPES, VARIABLES, OPERATORS
College of
College of
Computer
Computer VARIABLES
Click to edit
Studies
Studies Master title style

VALID VARIABLE NAMES INVALID VARIABLE NAMES

age float

totalPrice 2talPrice

_name @name

student3 skjbfdsjkf

ITC 121 : COMPUTER PROGRAMMING 2 TOPIC: DATA TYPES, VARIABLES, OPERATORS


College of
College of
Computer
Computer VARIABLES
Click to edit
Studies
Studies Master title style

Constant
a constant variable is a variable whose value
cannot be changed after it has been initialized or
defined. Once a constant variable is assigned a value,
that value remains constant throughout the program's
execution. Constant variables are often used to
represent values that are not expected to change, such
as mathematical constants (e.g., pi).
ITC 121 : COMPUTER PROGRAMMING 2 TOPIC: DATA TYPES, VARIABLES, OPERATORS
College of
College of
Computer
Computer OPERATORS
Click to edit
Studies
Studies Master title style
Operator is a symbol that tells the compiler or interpreter to perform
specific mathematical, relational or logical operation and produce final
result.
 Arithmetic operators (/, *, +, -, %)
 Unary operator (--, ++, !)
 Comparison Operators (<, <=, >, >=)
 Assignment Operators (=, +=, -=, /=, %=, *=)
 Logical Operator (&&, ||)
 Equality Operator (==, !=)
ITC 121 : COMPUTER PROGRAMMING 2 TOPIC: DATA TYPES, VARIABLES, OPERATORS

You might also like