cs3251 UNIT V QBANK
cs3251 UNIT V QBANK
Application Files:
These files contain executable code (programs) that perform specific tasks.
Examples: .exe (Windows executables), .app (macOS applications), .apk (Android apps).
Data Files:
Examples:
Spreadsheet Files: Organize data in rows and columns (e.g., .xlsx, .ods).
System Files:
These files are essential for the operating system and system utilities.
Examples:
Media Files:
Examples:
Image Files:
Audio Files:
Video Files:
Document Files:
Compressed Files:
These files bundle other files together for efficient storage or transfer.
Examples:
Executable Files:
These files contain machine code and can be run directly by the computer.
Use fopen() with attributes like "a" (append), "a+" (append and read), "w" (write), or "w+" (write
and read).
This function creates a new file or opens an existing one for writing or appending data.
You can open an existing file for reading or writing, depending on your needs.
To open a file, we use the fopen() function, which comes from the stdio.h header.
FILE *ptr;
Access Modes:
When you send out your invitations (i.e., open a file), choose the perfect mode:
"r": Open for reading. If the file doesn’t exist, fopen() returns NULL.
"rb": Open for reading in binary mode (useful for non-text files).
"w": Open for writing. If the file exists, its contents are overwritten. If not, a new file is created.
"wb": Open for writing in binary mode.
If the file exists, its contents are overwritten. If not, a new file is created.
The syntax
fclose(file_pointer);
Here, file_pointer is the pointer associated with the file you want to close.
Sequential Access:
When accessing data, you process it sequentially—one after another. To reach a specific item of
data, you must read all the data that precedes it.
Random Access:
directly access any item of data without reading everything that comes before it.
8 What is file? AP
A file is a collection of data or information, neatly bundled together and given a name—the
filename
files are organized into records The data inside the file is somehow organized. We call this
organization a file format.
9 A file ‘books.dat’ contains the data of various author books, write a code to access the file and AP
read its contents to display on console.
a) To set the position indicator in new position where the location is known
b) To save the current position of the indicator for future relocation of indicator.
State report generation involves creating structured and meaningful reports based on collected
data to provide insights and information for decision-making.
a transaction represents a logical unit of work that consists of one or more database operations
(such as reads, writes, or updates).
Part – B RBT
1 What is command line arguments? Write an example program for command line arguments AP
4 Write a C program to read name and marks of n number of students from user and store them in a AP
file?
5 Write a C program to write all the members of an array of structures to a file using fwrite(). Read AP
the array from the file and display on the screen
6 Explain about the random access? And gibe the properties of file operating AP
8 Write short notes on ferror(). ferror()? Write short notes on fscanf ().Write short notes on fprintf ().? AP
9 A file is created to store employee records with name, address, contact no, employee id, basic AP
salary, allowance and deduction. Write a C program to count number of records, display current
position of record, and moving position to the particular employee record.
10 A student record is stored as ‘student.dat’ with name and marks of ‘n’ number of students. Write a AP
C program to read and access them in a file to get the details of particular student or student with
particular marks, number of students with marks above or below average.