Description
Question 1
- Create a file called “number.dat” using the vi editor.
- Type set of numbers and save those in the file.
- e.g : 21 43 76 98 40
- Using a C program enter another number from the key board and store it in the if the file does not already have that number. If the number exist in the file, display an error message.
- Read the dat file and display all the numbers stored in the file.
Question 2
A medical center wants to store the appointment details of their patients in a text file called “appointment.dat”. The patient details consist of patient name and the type of appointment. Type of appointment can be either “Consulting”, “Scanning” or “Testing”. Only the first letter of the appointment type will be stored in the file.
Write a C program to do the following.
- Create a file called “appointment.dat”.
- Enter data of 5 patients from the keyboard and write those data to the text file(sample input is given below).
| Dilshan
Ruwan Mangala Ganesh Jithen |
C
T S C S |
- Read the dat file and calculate and display the number of patients of each type as given below.
Appointment Type Number of Patients
Consulting 2
Scanning 2
Testing 1




