Student database

From Programming In C

Exercise 6.2

The Students Database File link points to a data file which contains a (unspecified) number of student records. Save this file on your U: drive via:

  1. Open the link, copy and paste this data into a Word or Notepad document called student in the same directory as your source code. Save the file as ”Text only”, so that it will be called students.txt.

This text file represents a simple student database of student records with each row corresponding to a different (ficticious) student. The first and second columns correspond to the student's 5-digit student number and surname. The third column is the student's sex (M/F) and the final 3 columns are the student's date of birth in the form date (dd), month (mm) and year (yyyy) where dd, mm and yyyy are all integers.

Write a program that opens the file students.txt and for each student writes out the student's number and age on 1st November 2011. Write all male students to a file called M.txt and write all female students to a file called F.txt.

Note: the output must be formatted so that the student number is left-aligned and that the age is 2 digits and all ages are aligned in the same columns, for example:

12345    15
23456    17
34567    20

Return to the course summary

phy225: Course Details

general


compilers


2011-12 assessments


past exam papers

  • 2008-9 (http://physics-database.group.shef.ac.uk/exampapers/2008-09/PHY225%20LT.pdf)
  • 2009-10 (http://physics-database.group.shef.ac.uk/exampapers/2009-10/PHY225%20Exam%20Sem%201%202009-10.pdf)
  • 2010-11 (http://physics-database.group.shef.ac.uk/exampapers/2010-11/PHY225_10_11.pdf)