# Programming Fundamentals/Variables/Data Types

A data type is a classification of data which tells the compiler or interpreter how the programmer intends to use the data. Most programming languages support various types of data, including integer, real, character or string, and Boolean. This activity introduces data types. This activity will help you understand how and when to use different data types in a program.

## Objectives

* Understand data types.
* Understand how data types are specified in a program.
* Understand how data literals specify data types.

## Prerequisites

* Review Wikipedia: Data type.
* An integer data type represents whole numbers with no fractional parts.
* A real or floating-point data type represents fractional numbers with decimal points.
* A string data type represents a sequence of characters.
* A Boolean data type represents logical true or false.
* An operator is a character or symbol used to perform an arithmetic, logical, or bitwise operation on one or more operands.
* String concatenation is the joining of character strings end-to-end.
* An assignment statement sets and/or re-sets the value stored in the storage location(s) denoted by a variable name; in other words, it copies a value into the variable.

## Introduction

Review the flowchart example on the right.

### Questions

* What flowcharting symbol is used to indicate the beginning and ending of a program?
* What flowcharting symbol is used to indicate annotations or comments?
* What flowcharting symbol is used to indicate variable declaration?
* What flowcharting symbol is used to indicate input or output?
* What flowcharting symbol is used to indicate a process, calculation, or assignment?
* What key word is used to declare an integer variable?
* What key word is used to declare a real or floating-point variable?
* What key word is used to declare a string variable?
* What key word is used to declare a Boolean variable?
* How can you tell the difference between an integer literal value and a real or floating-point literal value?
* How can you tell the difference between a numeric literal value and a string literal value?
* What operator is used for assignment?
* What operator is used for string concatenation?

## Activity

With a partner, perform the following:
* Using a visual programming language, create a program matching the flowchart on the right.
* Save the program.
* Test the program to verify that it works correctly.
* Trade places, so that both partners have an opportunity to "drive" the visual programming environment.
* Copy the program and change it so that different values are used for each data type.
* Save the program.
* Test the program to verify that it works correctly.
* Working together, create a list of examples for which you would use each of the different data types in a program. Include at least three examples for each data type.
** integer
** real or floating-point
** string
** Boolean

## Applications

* Identify the data types necessary for processing data to meet given program requirements.
* Discuss your activity experience with your classmates. What surprised you? What have you learned that you can apply to your own school or work environment?