variable & data type (cse-122)

17
Variables & Data type

Upload: md-ashaf-uddaula-tanvir

Post on 21-Jan-2018

80 views

Category:

Documents


3 download

TRANSCRIPT

Page 1: Variable & Data type (CSE-122)

Variables&

Data type

Page 2: Variable & Data type (CSE-122)

Course: CSE 122(Programming and Problem Solving)

Course Teacher: Ms. Rabeya Akhter

Section:P Depertment:CSE(43 Batch)

Group Members:

01. Md. Ashaf Uddaula (161-15-7473)

02. Alamin Hossain (161-15-7483)

03. Md. Khasrur Rahman (161-15-7214)

04. Md. Eram Talukder (161-15-7485)

05. Ijaz Ahmed Utsa (161-15-7180)

Page 3: Variable & Data type (CSE-122)

What is Variable?

Components of a Variable

Rules of Using Variable

Case Sensitivity

What is Data Type?

Classification of Data Type

Description of Some Data Types in Details

Page 4: Variable & Data type (CSE-122)

What is Variable?

A variable is a data name that may be used to store a data value.

A variable may take different values at different times during execution.

A variable can be chosen by the programmer in a meaningful way.

Page 5: Variable & Data type (CSE-122)

Components of a Variable

Page 6: Variable & Data type (CSE-122)

Rules of Using Variable

A variable must begin with a letter . Some systems may permit underscore as first character.

Uppercase & lowercase are significant . The variable "TOTAL" is different from "total" & "Total".

It should not be keyword.

Page 7: Variable & Data type (CSE-122)

Rules of Using Variable

Whitespace is not allowed.

Length should be normally more than 8 characters are treated as significant by many compilers.

Examples of valid variables are:

john,x1,T,raise,first,tag.

Examples of invalid variables area:

123,(area),25@,price$.%.

Page 8: Variable & Data type (CSE-122)

C is case sensitiveIt matters whether an identifier, such as a variable name, is uppercase or lowercase.

Example:

area

Area

AREA

ArEa

are all seen as different variables by the compiler.

Page 9: Variable & Data type (CSE-122)

What is Data Type?

Data type is a data storage formate that can contain a specific type or range of values.

When computer programs store data in variables, each variable must be assinged a specific data type.

Data types represents the type of information that can be stored in a variable.

Data types are the keywords, which are used for assigning a type to a variable.

Page 10: Variable & Data type (CSE-122)

Classification of Data Type

Page 11: Variable & Data type (CSE-122)

Description of Some Data Types in Details:

Integer Float Double

Character Void

Page 12: Variable & Data type (CSE-122)

Integers are whole numbers with a range of values supported by particular machine.

Integers occupy one word storage generally & since the word sizes of machine vary the size of interger that can be stored depends on computer.

If we use 16-bit word length,the size of integer value is limited to range -32768 to 32767

Page 13: Variable & Data type (CSE-122)

If we use 32-bit word length can store an integer ranging from -2147483648 to 2147483647.

In order to provide control over range of numbers & storage space C has 3 classes of integer storage namely: short int, int, long int in both signed & unsigned.

Short int represents fairly small integer values 7 requires half amount as regular int number uses.

Page 14: Variable & Data type (CSE-122)

Floating point numbers are stored in 32-bits , with 6 digit precision.

Floating point numbers are defined by keyword "float".

When accuracy is provided by a float number is not sufficient, double can be used to define numbers.

A double data type number uses 64-bits giving a precision of 14 digits.

Page 15: Variable & Data type (CSE-122)

These are known as double precision number.

Double data type represents the same data type that float represents but with greater precision.

To extend the precision we may use long double which uses 80 bits.

Page 16: Variable & Data type (CSE-122)

A single character can be defined as a character (char) type data.

Characters are usually store in one byte of internal storage.

Qualifier signed or unsigned may be used in char explicitly. Unsigned characters have values between 0 & 255, signed characters have values from -128 to 127.

Page 17: Variable & Data type (CSE-122)

Void type has no values.This is used to specify the type of function.

The type function is said to be void when it doesn't return any value to calling function.

EndThank You