0% found this document useful (0 votes)
2 views2 pages

Module 2 Notes

Data types in C specify the kind of value a variable can hold and determine its memory size. They are classified into primary data types (such as int, float, char, and void) and derived data types (like arrays, structures, and unions). Primary data types are built-in, while derived data types are user-defined.

Uploaded by

divya
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views2 pages

Module 2 Notes

Data types in C specify the kind of value a variable can hold and determine its memory size. They are classified into primary data types (such as int, float, char, and void) and derived data types (like arrays, structures, and unions). Primary data types are built-in, while derived data types are user-defined.

Uploaded by

divya
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

1.

EXPALIN DATATYPES IN C:
Ans:
 Data types in the c programming language are used to specify what kind of
value can be stored in a variable.
 The memory size and type of the value of a variable are determined by the
variable data type.
 In the c programming language, data types are classified as
follows...

 Primary data types: The primary data types in the C programming language are
the basic data types. All the primary data types are already defined in the
system. Primary data types are also called as Built-In data types.
Integer: We use the keyword "int" to represent integer data type in c.
• We use the keyword int to declare the variables and to specify the return type of a
function.
• The integer data type is used with different type modifiers like Short (2bytes),
long (4 bytes), signed (2bytes) and unsigned (2bytes).
The access specifier for integer data type is %d.
Float: Floating-point data types are a set of numbers with the decimal value. Every
floating-point value must contain the decimal value. The floating-point data type
has two variants: Float and double
 We use the keyword "float" to represent floating-point (4 bytes) datatype and
"double" to represent double (8 bytes) data type in c.
 The float value contains 6 decimal places whereas double value contains 15 or
19 decimal places.
 The access specifier for float is %f and double is %ld

Character data type


 The character (1 byte) data type is a set of characters enclosed in single
quotations. We use the keyword char.
 The access specifier for character type is %c.

void data type


The void data type means nothing or no value. Generally, the void is used to
specify a function which does not return any value. We also use the void data type
to specify empty parameters of a function.
Enumerated data type
An enumerated data type is a user-defined data type that consists of integer
constants and each integer constant is given a name. The keyword "enum" is used
to define the enumerated data type.
Derived data types
Derived data types are user-defined data types. The derived data types are also
called as user-defined data types or secondary data types. In the c programming
language, the derived data types are created using the following concepts...
 Arrays
 Structures
 Unions

You might also like