You are on page 1of 2

Assignment 2

1. Identify all data types use in C programming and explain each one

INT

· An integer data type represents some range of mathematical integers. Integral data types may
be of different sizes and may or may not be allowed to contain negative values. Integers are
commonly represented in a computer as a group of binary digits (bits). The size of the grouping
varies so the set of integer sizes available varies between different types of computers and
different programming languages

CHAR

· The CHAR data type stores character data in a fixed-length field. Data can be a string of single-
byte or multibyte letters, numbers, and other characters that are supported by the code set of
your database locale.

STRING

· A string data type is traditionally a sequence of characters, either as a literal constant or as some
kind of variable. The latter may allow its elements to be mutated and the length changed, or it
may be fixed (after creation). A string is generally considered a data type and is often
implemented as an array data structure of bytes (or words) that stores a sequence of elements,
typically characters, using some character encoding.

FLOAT

· The FLOAT data type stores double-precision floating-point numbers with up to 17 significant
digits. FLOAT corresponds to IEEE 4-byte floating-point, and to the double data type in C. The
range of values for the FLOAT data type is the same as the range of the C double data type on
your computer.

2. Differentiate double and float, charater and string data types


The difference about double and float

Double has 2x more precision than float. float is a 32-bit IEEE 754 single precision Floating Point
Number – 1 bit for the sign, 8 bits for the exponent, and 23* for the value. float has 7 decimal
digits of precision. double is a 64-bit IEEE 754 double precision Floating Point Number – 1 bit for
the sign, 11 bits for the exponent, and 52* bits for the value. double has 15 decimal digits of
precision.

The difference about character and string

The main difference between Character and String is that Character refers to a single letter,
number, space, punctuation mark or a symbol that can be represented using a computer while
String refers to a set of characters. In C programming, we can use char data type to store both
character and string values.

You might also like