0% found this document useful (0 votes)
18 views1 page

Assignment - 34

Uploaded by

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

Assignment - 34

Uploaded by

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

Assignment -34 A Job Ready Bootcamp in C++, DSA and IOT MySirG

File Handling

1. Write a C++ program to create a file and print “File created successfully” and throw
an error if file is not created.
2. Write a C++ program to read a text file and count the number of characters in it.
3. Write a C++ program to open an output file 'a.txt' and append data to it.
4. Write a program to copy the contents of one text file to another while changing the
case of every alphabet.
5. Write a C++ program to merge the two files.
6. Write a C++ program that counts the total number of characters, words and lines in
the file.
7. There are 50 records in a file. Each record contains 6-character item-code, 20
characters for item-name and an integer price. Write a program to read these
records, arrange them in the descending order of price and write them in the same
file, overwriting the earlier records.
8. A file 'Employee.txt' contains empno and empname. Write a C++ program to add and
read contents of this file and search for an employee whose name is 'XYZ'.
9. A company has following details of their employees in the file 'emp.dat'
a. Emp Id
b. Emp Name
c. Emp Address
d. Emp Dept (Admin/Sales/Production/IT)
e. Emp Phone
f. Emp Age

Write a C++ program to read the above file. Create a new file such as Adm.dat,
Sal.dat, Pro.dat, IT.dat respectively to store the employee details according to their
department.
10. Write a C++ program to create a file which has information Name, Account number,
Balance and perform following operations:
a. Add record
b. Display content of file
c. Display name of person having balance > 10,000

You might also like