0% found this document useful (0 votes)
2K views

File Handling Ass

1. The document provides 10 programming assignments related to file handling in C++. The assignments involve tasks like changing characters in a file, copying records between files based on certain conditions, reading and writing to binary files, and displaying records from a file based on a field value. 2. The assignments cover concepts like file input/output, string manipulation, structure of records in a binary file, reading/writing specific fields, and positioning the file write pointer. 3. The tasks get progressively complex, involving functions, classes, structures, and comparing fields to filter records for specific output.

Uploaded by

Niti Arora
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2K views

File Handling Ass

1. The document provides 10 programming assignments related to file handling in C++. The assignments involve tasks like changing characters in a file, copying records between files based on certain conditions, reading and writing to binary files, and displaying records from a file based on a field value. 2. The assignments cover concepts like file input/output, string manipulation, structure of records in a binary file, reading/writing specific fields, and positioning the file write pointer. 3. The tasks get progressively complex, involving functions, classes, structures, and comparing fields to filter records for specific output.

Uploaded by

Niti Arora
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 3

Class XII File Handling Assignment

1. Write a program to accept the file name from the user and change all the occurrences of A with a 2. Write a program to accept the file name from the user and convert A to B, B to C and so on and Z to A 3. Write a program to accept the file name from the user and find a character in the file tell how many times it occurs in the file. 4. Write a function in C++ to print the count of the word is as an independent word in a text file DIALOGUE.TXT. For example,if the content of the file DIALOGUE.TXT is This is his book. Is this book good ? Then the output of the program should be 2. 5. Write a program to delete all the words starting with a vowel from file abc.txt. 6. Consider a class Class EMPLOYEE { int ENC; char ENAME[0]; PUBLIC: Void GETIT(){ cin>> ENO;gets(ENAME);} Void SHOWIT() { cout>> ENO<<ENAME;<<endl; } }; Write a menu driven program to read and write in the binary data file emp.dat 7. Given a binary file PHONE.DAT, containing records of the following structure type class phonlist { char Name[20] ; char Address[30] ; char AreaCode[5] ; char PhoneNo[15] ; public ; void Register( ) ; void Show( ) ; int CheckCode(char AC[ ]) { return strcmp(AreaCode, AC) ; } }; Write a function TRANSFER( ) in C++, that would copy all those records which are having AreaCode as .DEL. from PHONE.DAT to PHONBACK.DAT. 8. Observe the program segment given below carefully, and answer the question that follows : class PracFile { int Pracno ; char PracName[20] int TimeTaken ; int Marks ; public :

void EnterPrac( ) ;//Function to enter PracFile details void ShowPrac( ) ://Function to display PracFile details int RTime( ) //function to return Time Taken {return TimeTaken;} void Assignmarks(int M) //Function to assign Marks { Marks = M ;} }; void AllocateMarks( ) { fstream File ; File.open (.MARKS.DAT., ios :: binary l ios :: in l ios :: out ) ; PracFile P ; int Record = 0 ; while (File.read ( (char*) &P, sizeof (P) ) ) { if (P.RTime( ) > 50) P.Assignmarks(0) Else P.Assignmarks(10) ___________________________________ __________________________________________ Record++ ; } File . close( ) ; } If the function AllocateMarks( ) is supposed to Allocate Marks for the records in the file MARKS.DAT based on their value of the member TimeTaken. Write C++ statements for the statement 1 and statement 2, where, statement 1 is required to position the file write pointer to an appropriate place in the file and statement 2 is to perform the write operation with the modified record. 9. Given a binary file GAME.DAT, containing records of the following structure type struct Game { char GameName[20] ; char Participate[10][30] ; }; Write a function in C++ that would read contents from the file GAME.DAT and creates a file named BASKET.DAT copying only those records from GAME.DAT where the game name is Basket Ball. 10. Given a binary file STUDENT.DAT, containing records of the following class Student type class Student { char S_Admno[10] ; //Admission number of student char S_Name[30] ; //Name of student int Percentage ; //Marks Percentage of student public : void EnterData( ) { gets(S_Admno) ; gets(S_Name) ; cin >> Percentage ; } void DisplayData( ) { cout << setw(12) << S_Admno ; cout << setw(32) << S_Name ; cout << setw(3) << Percentage << endl ; }

int ReturnPercentage( ) {return Percentage ;} }; Write a function in C++, that would read contents of file STUDENT.DAT and display the details of those Students whose Percentage is above 75.

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy