Welcome !!

NICETECHVIDYA

Tutorials

Web Designs

You are welcome to Aptech Designers, designed by Pratik from Nepal.

Creativity is my passion. Logo describes your details about company.

Graphics Design needs vision to create yours unique digital concept.

Responsive and All Browser Compatible Dynamic Web Layouts our target.

Home Python C Language J A V A Our Courses
This WebSite is under Construction....

Thursday 10 March 2022

14.Computer memory

 

Computer memory:

RAM is the primary, main or conventional memory of computer.

It is used to store the data, instructions and intermediate results.

It is a volatile memory, looses its data on termination of program or function.

The total memory is divided into number of bytes.

Each byte is divided into 8 bits.

Every byte is identified with a number called address (It is a positive number).

 

 

 


Scale of memory:

 

1 byte

8 bits

1024 bytes

1 Kilo Byte(KB)

1024 KB

1 Mega Byte(MB)

1024 MB

1 Giga Byte(GB)

1024 GB

1 Tera Byte(TB)

 

Data types in C Language:

 

C language is rich in data types, provides number of data types to allocate the memory of different types of different ranges.

Total data types in C language are classified into

Primary data types.

Derived data types.

User defined types.

In this session we are discussing the primary data types. 


Primary data types in C language:

The primary data types in C language are classified into

 

 

 

 

 

 


   

int:

It is the primary type in C language used to store integer constant.

It takes two bytes of memory (16 bits)

The higher most bit is used to store the sign. 0 for + and 1 for –

Left all the 15 bits are used to store actual value in a binary format.

When an integer is assigned to the variable, then it will be first converted into its binary equal and stores into the memory.

Range of integer is -32768 to 32767 (-215 to +215-1)

%d is used as the representation character for integers.

Example: (Integer representation)

 

 

 

 

 

 

 

 

 

 

 

 

 


    

Example explained:

Though int type cannot store more than 40000, unsigned int is capable to store 40000. Because, the range of unsigned int is double to the int.

The output of y is not as we expected, because, unsigned type cannot handle negative values.

 

float, double, long double:

These are the floating point types used to store the real constants of different ranges.

float takes 4 bytes, double takes 8bytes and long double takes 10 bytes of memory.

The range of float is 3.4x10-38 to 3.4x10+38, double is 1.7x10-308 to 1.7x10+308 and long double is 3.4x10-4932 to 1.1x+4932 .

Representation character to float is %f, double is %lf and long double is %Lf.

 

0 comments:

Post a Comment