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

C++ File Handling Assignments Guide

The document provides 10 file handling problems involving C++ programs: 1. Change all occurrences of A to 2 in a file 2. Convert letters sequentially in a file 3. Count occurrences of a character in a file 4. Count a word in a text file 5. Delete words starting with vowels from a file 6. Menu driven program to read/write binary employee data file 7. Copy records with given area code from one binary file to another 8. Modify records in a binary file based on a condition and write to file 9. Copy records with a given game name to a new binary file 10. Display records from a binary file with percentage above a value

Uploaded by

Kartik Gupta
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
22 views2 pages

C++ File Handling Assignments Guide

The document provides 10 file handling problems involving C++ programs: 1. Change all occurrences of A to 2 in a file 2. Convert letters sequentially in a file 3. Count occurrences of a character in a file 4. Count a word in a text file 5. Delete words starting with vowels from a file 6. Menu driven program to read/write binary employee data file 7. Copy records with given area code from one binary file to another 8. Modify records in a binary file based on a condition and write to file 9. Copy records with a given game name to a new binary file 10. Display records from a binary file with percentage above a value

Uploaded by

Kartik Gupta
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd

Class XIIFile Handling Assignment 1.

Write a program to accept the file name from the user and change all the occurrences of A with a [Link] a program to accept the file name from the user and convert A to B, B to C and so on and Zto A [Link] a program to accept the file name from the user and find a character in the file tell how manytimes it occurs in the file .[Link] a function in C++ to print the count of the word is as an independent word in a text [Link] example,if the content of the file [Link] isThis is his book. Is this book good ?Then the output of the program should be 2. [Link] a program to delete all the words starting with a vowel from file [Link]. 6 . C o n s i d e r a c l a s s 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 [Link] 7. Given a binary file [Link], containing records of the followingstructure typeclass 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 AreaCodeas .DEL. from [Link] to [Link].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 detailsvoid ShowPrac( ) ://Function to display PracFile detailsint RTime( ) //function to return Time Taken{return TimeTaken;}void Assignmarks(int M) //Function to assign Marks{ Marks = M ;}} ;void AllocateMarks( ){ fstream File ;[Link] (.[Link]., ios :: binary l ios :: in l ios :: out ) ;PracFile P ;int Record = 0 ;while ([Link] ( (char*) &P, sizeof (P) ) ){ if ([Link]( ) > 50)[Link](0)[Link](10) Record++ ;}File . close( ) ;}If the function AllocateMarks( ) is supposed to Allocate Marks for the records in the [Link] based on their value of the member TimeTaken. Write C++ statements for the statement1 and statement2 , where, statement1 is required to position the file write pointer to anappropriate place in the file and statement2 is to perform the write operation with the modifiedrecord.9. Given a binary file [Link], containing records of the following structure typestruct Game{ char GameName[20] ;char Participate[10][30] ;} ;Write a function in C++ that would read contents from the file [Link] and creates a file [Link] copying only those records from [Link] where the game name is Basket Ball.10. Given a binary file [Link], containing records of the following class Student typeclass Student{ char S_Admno[10] ; //Admission number of studentchar S_Name[30] ; //Name of studentint 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 [Link] and display the details of those Students whose Percentage is above 75.

You might also like