Programming for Problem Solving (3110003)

BE | Semester-1   Winter-2019 | 07-01-2020

Q1) (b)

Distinguish the data types provided by C programming language.

A data type is a data name to store data values. It is a classification of various types of data, as floating-point, integer, or string.

Primary Data Types:

Primary data types are built in data types. It is also known as fundamental data types. Four data types available in primary data types are int, float, char, and void.
 
integer
int is an integer which is a whole number without a fractional part. It has 3 classes of integer storage namely short int, int and long int.
  signed unsigned
Size (bits) Range Size (bits) Range
short int 8 -128 to 127 8 0 to 255
int 16 -32768 to 32767 16 0 to 65535
long int 32 -2147483648 to 2147483647 32 0 to 4294967295
 
char
char data type can store a single character of alphabet or digit or special symbol. Each character is assigned some integer value which is known as ASCII values.
  signed unsigned
  Size (bits) Range Size (bits) Range
char 8 -128 to 127 8 0 to 255
 
float
Float data types can store floating point numbers which represent a real number with decimal point and fractional part.
  signed unsigned
  Size (bits) Range Size (bits) Range
short int 8 -128 to 127 8 0 to 255
int 16 -32768 to 32767 16 0 to 65535
long int 32 -2147483648 to 2147483647 32 0 to 4294967295
 
void
The void type has no value and it cannot be used for variable declaration. The void data type is used to indicate that function is not returning anything.
 

Secondary Data Types:

It is a combination of primary and secondary data types to handle real life data in a convenient way. It is further classified into following types.
 
Derived Data types
It is an extension of primary data types.
Array An array is a fixed size sequenced collection of elements of the same data type.
Pointer Pointer is a variable that contains the memory address of another variable.
 
User defined Data types
User defined data types are created by programmers using a combination of primary and derived data types.
structure Structure is a collection of logically related data items of different data types grouped together under a single name.
union Union is like a structure, except that each element in it shares the common memory.
enum It consists of named constants called enumerators. The enumerator names are usually identifiers that behave as constants.