1.1- Basics before Introductions of Data Structure

The objective of this blog is to explain the importance of analysis of algorithms, Relationships, and solving as many problems as possible.

Variable – In Mathematics variable is “a quantity which during a calculation is assumed to vary or be capable of varying in value” for example if an equation is 3x +2y =5, then x and y are the variables which have some value. but in the context of computer science, the variable defined as –

A data item that may take on more than one value during the runtime of a program.

Data Type – A data type in a programming language is a set of data with predefined values such as integral numbers (70,90). Examples of data types are an integer, floating point, character, string, etc.

At the top level there is two type of data type:

  1. System-define data types (also knows as Primitive data type)
  2. User-define data types

1. Primitive data type

Data types that defined by the system are called Primitive data types.

The primitive data type provided by many programming languages are int, float, char, double, boolean, etc. The number of bits allocated for each primitive data type, different languages may use different sizes. Depending on the size of the data types the total available values (domain) will also change. for example in Java following are available values-

                                                  Primitive data types in Java
Type Description Default Size Example Literals
boolean true or false false 1 bit true, false
byte twos complement integer 0 8 bits N/A
char Unicode character \u0000 16 bits 'a', '\u0041', '\101', '\\', '\n','\''
short twos complement integer 0 16 bits N/A
int twos complement integer 0 32 bits -2, -1, 0, 1, 2
long twos complement integer 0 64 bits -2L, -1L, 0L, 1L, 2L
float IEEE 754 floating point 0.0 32 bits 1.23e100f, -1.23e-100f, .3f, 3.14F
double IEEE 754 floating point 0.0 64 bits 1.23456e300d, -1.23456e-300d, 1e1d

2. User-defined data types

When programmer defines own data types instead of primitve data type that data type called User-defined data type (UDT) i.e

Data type which is defined by the user.

public class UserDataType{
// in this program UserDataType class is example of user-define
// data type.
}

Now programmer can use UserDataType as a user-define data type. This give more flexibility and comfort in dealing with computer memory.

Thank you all.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

Blog at WordPress.com.

Up ↑

%d bloggers like this: