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

Lesson 6 ICT 1

The document discusses data types and variables in C programming. It identifies the basic data types in C as integers, floating-point numbers, characters, and variables. Integers represent whole numbers, floating-point numbers can have fractional parts, and characters represent single character symbols. Variables provide temporary storage for values and have naming rules like only including letters, numbers, and underscores, and not beginning with a number or using keywords. The document also provides examples of declaring different data types and variables in C code.

Uploaded by

Liam Pitchan
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)
90 views

Lesson 6 ICT 1

The document discusses data types and variables in C programming. It identifies the basic data types in C as integers, floating-point numbers, characters, and variables. Integers represent whole numbers, floating-point numbers can have fractional parts, and characters represent single character symbols. Variables provide temporary storage for values and have naming rules like only including letters, numbers, and underscores, and not beginning with a number or using keywords. The document also provides examples of declaring different data types and variables in C code.

Uploaded by

Liam Pitchan
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/ 39

REVIEW

Lesson 6:
DATA TYPE & VARIABLES

ICT 1 | Fundamental in Computer


Programming
OBJECTIVES
• Identify the data types of Programming C;
• Explain the rules of declaring variables; and
• Write the code with declaring variable and data type
type variable;
DATA TYPE
a set of data with values having predefined
characteristics.
BASIC TYPES OF
DATA TYPE
INTEGERS
represent signed whole number

BASIC TYPES OF DATA TYPE


int x;
BASIC TYPES OF DATA TYPE
int x = 1;
BASIC TYPES OF DATA TYPE
int x = 1234;
BASIC TYPES OF DATA TYPE
type variable = value;

BASIC TYPES OF DATA TYPE


FLOATING-POINTS
can be numbers with fractional part

BASIC TYPES OF DATA TYPE


float y;
BASIC TYPES OF DATA TYPE
float y = 1.0;
BASIC TYPES OF DATA TYPE
float y = 12.34;
BASIC TYPES OF DATA TYPE
double z;
BASIC TYPES OF DATA TYPE
double z =
1.00;
BASIC TYPES OF DATA TYPE
double z =
1234.5678;
BASIC TYPES OF DATA TYPE
CHARACTERS
as char symbols in a character set that is similar to
letters and numbers.

BASIC TYPES OF DATA TYPE


char c;
BASIC TYPES OF DATA TYPE
char c = ‘a’;
BASIC TYPES OF DATA TYPE
type variable;
type variable;
VARIABLE
It is temporary storage for values that you will use in
program.
VARIABLE
NAMING RULE
ONLY LETTERS, NUMBERS
AND UNDERSCORE.
INVALID VALID
First!n@me first_name
last-name lastName

VARIABLE NAMING RULE


MAY NOT BEGIN WITH A
NUMBERS
INVALID VALID
1stName firstName
3rdPlace _3rdPlace
2ndNumber Number2

VARIABLE NAMING RULE


NO SPACE ALLOWED

INVALID VALID
first name firstname
last name lastname

VARIABLE NAMING RULE


NO KEYWORDS

INVALID VALID
static static4
case Mycase
void voidSpacing

VARIABLE NAMING RULE


auto double int struct

break else long switch

case enum register typeof

char extern return union

continue for signed void

do if static while

default goto sizeof volatile

const float short unsigned


DATA TYPE SIZE FORMAT SPECIFIER

int 2-4 %d, %i


float 4 %f
double 8 %lf
char 1 %c
How important to use data type and
variable in C language?

You might also like