100% satisfaction guarantee Immediately available after payment Both online and in PDF No strings attached 4.6 TrustPilot
logo-home
Summary

Summary data types and file & file handling

Rating
-
Sold
-
Pages
13
Uploaded on
18-01-2026
Written in
2025/2026

This document contains all the key concepts of data types and file handlings










Whoops! We can’t load your doc right now. Try again or contact support.

Document information

Uploaded on
January 18, 2026
Number of pages
13
Written in
2025/2026
Type
Summary

Subjects

Content preview

UNIT V
USER DEFINED DATA TYPES & FILE HANDLING
Syllabus:
User-defined data types: Structure and Union, Dynamic memory allocation.
Introduction to file concepts, File handling operations.
User-Defined Data Types
User-defined data types allow programmers to define their own data types to store
heterogeneous data efficiently.
Types of User-Defined Data Types
Structure (struct)
Union (union)
Enumeration (enum)
Typedef (typedef)
Structure
Definition
A structure is a collection of variables of different data types grouped under a
single name.
Syntax
struct structure_name {
data_type member1;
data_type member2;
};
Example
struct Employee {
int id;
char name[20];
float salary;
};
Declaration of Structure Variables:
struct Employee e1, e2;
Accessing Structure Members:
e1.id = 101;
printf("%d", e1.id);
Initialization:
Structure initialization means assigning values to structure members at the time of
declaration.
It helps in setting initial values easily and improves code readability.

, struct Student {
int roll;
char name[20];
float marks;
};
struct Student s1 = {101, "Anil", 85.5};
Structure Input Using scanf():
struct Student {
int roll;
char name[20];
float marks;
};
Void main(){
struct Student s1;
scanf("%d", &s1.roll);
scanf("%s", s1.name);
scanf("%f", &s1.marks);
printf("%d", s1.roll);
printf("%s", s1.name);
printf("%f", s1.marks);
}
Memory Allocation in Structures:
Memory allocation in structures refers to how memory is reserved for structure
variables and their members.
Memory is allocated when a structure variable is declared, not when the structure is
defined.
struct Student
{
int roll;
char name[20];
float marks;
};
struct Student s1;
Memory Allocation
Memory is allocated only when s1 is declared
Total memory = sum of sizes of all members
Example:
int → 4 bytes
char[20] → 20 bytes
float → 4 bytes
Total = 28 bytes
Example program:
£5.77
Get access to the full document:

100% satisfaction guarantee
Immediately available after payment
Both online and in PDF
No strings attached

Get to know the seller
Seller avatar
tabassumy

Also available in package deal

Thumbnail
Package deal
C programming
-
5 2026
£ 28.83 More info

Get to know the seller

Seller avatar
tabassumy
View profile
Follow You need to be logged in order to follow users or courses
Sold
New on Stuvia
Member since
2 weeks
Number of followers
0
Documents
17
Last sold
-

0.0

0 reviews

5
0
4
0
3
0
2
0
1
0

Recently viewed by you

Why students choose Stuvia

Created by fellow students, verified by reviews

Quality you can trust: written by students who passed their exams and reviewed by others who've used these revision notes.

Didn't get what you expected? Choose another document

No problem! You can straightaway pick a different document that better suits what you're after.

Pay as you like, start learning straight away

No subscription, no commitments. Pay the way you're used to via credit card and download your PDF document instantly.

Student with book image

“Bought, downloaded, and smashed it. It really can be that simple.”

Alisha Student

Frequently asked questions