Article Share Weblog

Read Share Support

Lab 06: Structure Variables and File Processing Part-II

Posted by Fawad Ishaq on July 4, 2008

| Ask an Expert | Live Programming Help |

Instructions

  • You must have installed Microsoft Visual Studio 6.0/Microsoft Visual Studio .NET 2003/Microsoft Visual Studio .NET 2005 on your machine to try the programs.
  • To develop the C++ program on Microsoft Visual Studio 6.0 please read the handout “How to create your first C++ program using Visual C++ 6.0”.
  • To develop the C++ program on Microsoft Visual Studio .NET 2003 please read the handout How to create your first C++ program using Visual C++ .NET 2003.
  • To develop the C++ program on Microsoft Visual Studio .NET 2005 please read the handout How to create your first C++ program using Visual C++ .NET 2005.

Exercise 01
1. Define a structure Employee consisting of following data members:
• Employee code (use integer type variable to store the employee code)
• Employee name (use char array of 50 elements to store the employee name)
• Department Code (use integer type variable to store the department code)
• Department name (use char array of 50 elements to store the department name)
• Salary (use double type variable to store the employee salary)
2. Define a function initEmployee to initialize the variable of Employee type.
void initEmployee ( Employee )
3. Define a function saveEmployee to save the employee data to a Employee.dat file.
void saveEmployee( Employee )
4. Declare a variable of type Employee and initialize it using initEmployee function.
5. Save the employee data to Employee.dat file using saveEmployee function.
6. Create a separate program that should only write the data to an output file.

Exercise 02
1. Define a structure Employee having following data members:
• Employee code (use integer type variable to store the employee code)
• Employee name (use char array of 50 elements to store the employee name)
• Department Code (use integer type variable to store the department code)
• Department name (use char array of 50 elements to store the department name)
• Salary (use double type variable to store the employee salary)
2. Define a function printEmployee to print the employee data on the console.
void printEmployee( Employee )
3. Define a function readEmployee to read the Employee data from a file.
void readEmployee ( Employee )
4. Declare a variable of type Employee.
5. Read employee data from Employee.dat file (created in exercise 01) and store in variable of type Employee using the readEmployee function.
6. Print the employee data on the console using the printEmployee function.
7. Create a separate program that should only read the data from a file and print it.

How to submit
1. Submit your assignments to Mr. Adeel as per the schedule announced by him.
2. No assignment shall be evaluated/accepted after the due date.
3. Copy assignments will be cancelled.
4. There will be an individual viva of this assignment. Your evaluation is strictly based on your performance in the viva.
5. Non-professional behavior during the viva may lead to assignment cancellation.

Ask an Expert - Visit my Virtual Office at LivePerson


| Download PDF Here |

Leave a Reply

You must be logged in to post a comment.