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

Datatypes

IT

Uploaded by

jsh96311
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 views7 pages

Datatypes

IT

Uploaded by

jsh96311
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/ 7

DATA TYPES

Mrs. Palmer
What is a data type?

This is simply saying what type of data will your variable (container)
hold.
.

Just as how you have a bag (container) to hold books, a


wallet(container) to store money and cards, a bottle (container) to
store water.

There are 4 basic data types in algorithm- string, character, real and
integer.
Data types
Textual Numerical

Character: this is used to Integer: this is used when


hold a single character for the desire is to store a whole
example a letter or symbol. number for example number
of students in class.

String: this is used to hold a Real: this is used to hold a


group of characters for decimal. Whether negative
example the name of a person or positive. For example,
the price of an item.
Boolean: this data is data that must
be either true or false. For example,
whether a person is married or not.
Let’s declare
some variables

Write an algorithm that accepts the price and quantity of an item


and print the total price.

•Declare price as REAL


•Declare quantity as REAL
•Declare total_price as REAL
Activity 1
The following table gives some examples of
the various data types.

Data Type
The grade a student
got in a course
The time Usain Bolt
took to ran a race.
The number of books
in a person’s bag
Whether or not your
luggage is overweight
Activity 2
Identify the variable names and the data type for the
following questions:

1. Write a structured algorithm that prompts the user to


input the number of days in a month. Calculate and
print the number of hours in the month.

2. Write a program that reads two numbers find and


prints their sum, difference and product.

3. Write an algorithm that prompts the user to input the


name and price of an item and quantity purchased.
It should print the name, price, quantity and amount
due with appropriate labels.
Activity 3
Construct an IPO or
Defining Diagram for all
questions in Activity 2.

You might also like