0% found this document useful (0 votes)
16 views10 pages

Data Types in C

Uploaded by

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

Data Types in C

Uploaded by

kiruthika.ncse
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 10

Data Types in C

With Diagrams, Examples &


Explanation
Introduction to Data Types

• Data types define the type of data a variable


can store.
• They determine:
• • Size of data in memory
• • Range of values
• • Operations allowed
Classification of Data Types in C

• 1. Primitive (Basic) Data Types


• 2. Derived Data Types
• 3. Enumeration Data Types
• 4. User-defined Data Types
Primitive (Basic) Data Types

• int → stores integers (e.g., 5, -10)


• float → stores decimal numbers (e.g., 3.14)
• char → stores a single character (e.g., 'A')
• double → stores large decimal numbers
• void → represents no value
• Example: int age = 20; float pi = 3.14; char
grade = 'A';
Size & Range of Basic Data Types

• int → 2 or 4 bytes, range: -32,768 to 32,767


(16-bit)
• float → 4 bytes, range: ~3.4E-38 to 3.4E+38
• double → 8 bytes, range: ~1.7E-308 to
1.7E+308
• char → 1 byte, range: -128 to 127
Derived Data Types

• Array → collection of same type elements


• Pointer → stores memory address
• Structure → groups variables of different
types
• Union → memory sharing between variables
• Example: int arr[5] = {1, 2, 3, 4, 5}; int *ptr =
arr;
Enumeration Data Type

• User-defined set of named integer constants.


• Example: enum week {Mon, Tue, Wed, Thu,
Fri, Sat, Sun};
• enum week today = Wed;
User-Defined Data Types

• Created using typedef or struct.


• Provides flexibility for complex programs.
• Example: typedef unsigned int uint; uint age =
25;
Diagram Summary

• Primitive → int, float, char, double, void


• Derived → array, pointer, structure, union
• Enumeration → enum
• User-defined → typedef, struct
Conclusion

• Data types are essential for memory allocation


& program efficiency.
• Choosing the right data type improves
performance & reduces errors.

You might also like