Friday, 29 January 2021

Basic Data Types in C

Type: A type is a set of values and operations on those values. 

For example: Light switch can be compared to a type. It has two values( on and off), only two operations can be performed (Switch on and Switch Off)

A data type defines a set of values and the operations on that can be performed on them. Moreover a data type tells to the compiler 

  1. What type of data the program can handle
  2. How much memory is needed for that data.
  3. What type of operations that can be performed on those data.

1.Basic Data Types

i) Void Data type

  1. Designated by 'void' keyword.
  2. Used in front of a function which does not return any value.
  3. Used to create generic pointers.

ii) Integral Data type

The C language has three integral data types.

a) Boolean data type

  • Used to represent two values 'true' or 'false'
  • Designated by the keyword 'bool'

b) Character Data type

 The characters are used to form words, numbers and expressions depending upon the computer on which the program runs. There are two types of character types.

  • Signed characters which occupies one byte in memory and range from -128 to 127
  • Unsigned characters which occupies one byte in memory and range from 0 to 255
  • The format specifier used is %c

c) Integer Data type:

 An integer is a number without fractional part. C supports 4 different types of integer types.

Type

Size in bytes

Range

Format specifier

Short int

1

-27 to 27-1

%hd

Int

2

-215 to 215-1

%d

Long int

4

-231 to 231-1

%ld

Long long int

8

-261 to 261-1

%ud

d) Floating point type:

i) real data type

real data type represents the real numbers; A number with decimal part.

ii) imaginary data type

An imaginary number is used extensively in mathematics and engineering. An imaginary number is a real number which is multiple of square root of -1

iii) Complex numbers type

A complex number is a combination of real and imaginary number.

2. Derived Data Types

Derived Data types are derived from the basic data types.

Examples: Arrays, functions, pointers

3.User Defined Data types:

C allow us to define our own data types such as structures and unions.These are called user defined data types because the programmer or user creates them according to their needs.

0 comments:

Post a comment

Find Us On Facebook

Contact Us

Name

Email *

Message *

C Programming

More

C++ Tutorial

More

Java Tutorial

More

software engineering

More

MS Office

More

Database Management

More

Advertisement

Top