NOTE: All the three contribution is published here as it is. You can use any of these.
Project - Jan 2001
Q - IGNOU admits students for its MCA programme every year. After admission, students are alloted to various study centers across the country. The allotment should be done on the following basis:
a) A student should be attached to a study center if s/he has given preference for it in the application. At the same time, the allotment should be made only if the Study Centre is having vacant seats i.e.
allotment should not be made beyond the capacity of the Study Centre.
b) If there are no vacant seats in the Study Centre, then the student should be attached to a Study Centre which is nearest possible to his place of residence. Again, the allotment should not be made beyond the capacity of the Study Centre.
In the above ways, all the students who have been granted admission should be attached to Study Centres. Please make assumptions, wherever necessary. Now write a program in 'C' language to do the allotment of students to Study Centres as mentioned. Don't forget that the number of Study Centres are
fixed.
The project report should contain:
i) The code for the above program.
ii) A note justifying the data structures used.
iii) A note on risk factors, a user can face if he uses this software.
ANS -
MonikaP
#include <stdio.h>
#include <conio.h>
#include <stdlib.h>
#include <string.h>
#include <Math.h>
#define MAXSTUDYCENTER 20
void main()
{
FILE *fp, *fp1;
char another;
char choice;
int studentpin=0,stcenterpin=0,diffpin=100, mindiff=0;
int i=0;
int arr[MAXSTUDYCENTER];
struct student
{
int enrolmentno;
int studycenter;
char add[30];
int pin;
};
struct student e;
struct center
{
int studycenter;
char add[30];
int pin;
int totseats;
int vacseats;
};
struct center c;
long int recsize;
long int recsize1;
fp = fopen("MYNEWFILE.DAT","rb+");
if(fp==NULL)
{
fp=fopen("MYNEWFILE.DAT","wb+");
if(fp==NULL) {
puts("Cannot open student file");
exit(0);
}
}
fp1 = fopen("MYNEWFILECENTER.DAT","rb+");
if(fp1==NULL)
{
fp1=fopen("MYNEWFILECENTER.DAT","wb+");
if(fp1==NULL) {
puts("Cannot open center file");
exit(0);
}
}
recsize = sizeof(e);
recsize1 = sizeof(c);
while(1) {
printf("\n1. Add Student");
printf("\n2. List Student Details");
printf("\n3. Add Study Center");
printf("\n4. List Study Center Details");
printf("\n5. Exit");
printf("\nYour Choice");
scanf("\n%s",&choice);
switch(choice) {
case '1' :
fseek(fp,0,SEEK_END);
another = 'Y';
while(another =='Y')
{
printf("\nEnter Enrolmentno");
scanf("%d",&e.enrolmentno);
printf("\nEnter Study Center Code");
scanf("%d",&e.studycenter);
printf("\nEnter Address");
scanf("%s",e.add);
printf("\nEnter Pin Code");
scanf("%d",&e.pin);
rewind(fp1);
while(fread(&c,recsize1,1,fp1) ==1)
{
if(e.studycenter == c.studycenter)
{
if (c.vacseats == 0) {
printf("\nThere is no vacant seat in the prefered study center");
printf("\nAllocating nearest study center.......");
studentpin=e.pin;
rewind(fp1);
i=0;
while(fread(&c,recsize1,1,fp1) ==1) {
if(c.vacseats != 0){
stcenterpin=c.pin;
diffpin = stcenterpin-studentpin;
arr[i]=diffpin;
i++;
}
}
TOP
mindiff=arr[0];
for(int counter=0;counter<i;counter++) {
if(abs(mindiff) > abs(arr[counter]))
mindiff=arr[counter];
}
rewind(fp1);
while(fread(&c,recsize1,1,fp1) ==1) {
if(c.pin == mindiff+studentpin) {
c.vacseats=c.vacseats-1;
fseek(fp1, -recsize1,SEEK_CUR);
fwrite(&c,recsize1,1,fp1);
break;
}
}
}
else {
c.vacseats=c.vacseats-1;
fseek(fp1, -recsize1,SEEK_CUR);
fwrite(&c,recsize1,1,fp1);
break;
}
break;
}
}
printf("\nCenter Allocated...Details are : ");
printf("\nEnrolmentNo\tstudycenter\taddress\t\tpin"
);
printf("\n%d\t\t%d\t\t%s\t\t%d",e.enrolmentno,c.studycenter,c.add,c.pin);
e.studycenter=c.studycenter;
fwrite(&e,recsize,1,fp);
printf("\nAdd another Record (Y/N)");
fflush(stdin);
another = getche();
}
break;
case '2' :
{
rewind(fp);
while(fread(&e,recsize,1,fp) ==1){
printf("\nenrol no\tstudy center\taddress\t\tpin");
printf("\n%d\t\t%d\t%s\t\t%d",e.enrolmentno,e.studycenter,e.add,e.pin);
}
}
break;
case '3' :
fseek(fp1,0,SEEK_END);
another = 'Y';
while(another =='Y')
{
printf("\nEnter Center Code");
scanf("%d",&c.studycenter);
printf("\nEnter Address");
scanf("%s",c.add);
printf("\nEnter Pin Code");
scanf("%d",&c.pin);
printf("\nEnter Total Seats");
scanf("%d",&c.totseats);
c.vacseats = c.totseats;
fwrite(&c,recsize1,1,fp1);
printf("\nAdd another Record (Y/N)");
fflush(stdin);
another = getche();
}
break;
case '4' :
{
rewind(fp1);
while(fread(&c,recsize1,1,fp1) ==1) {
printf("\nstudycenter\taddress\t\tpin\t totseats\t vacseats" );
printf("\n%d\t\t%s\t\t%d\t\t%d\t\t%d",c.studycenter,c.add,c.pin,c.totseats,c.vacseats);
}
}
break;
case '5' :
{
exit(0);
}
break;
default :
printf("\nPlease Enter Valid Choice\n");
}
}
}
PROJECT REPORT
Summary:
The project allot IGNOU students to various study centers after their admission. The student is alloted to the center he has opted for
, if there is any vacant seat in that study center and if there is no vacant seat in that study center, the center nearest to studentfs residence is
alloted. I have made pin code as the basis of distance in this project. Smaller the pin code difference of two places , smaller the distance between
the two places.
Assumptions Made:
1) The number of study center is fixed. It is taken as 20.
2) Pin Code is made the basis to find the distance between two places.
Note justifying the data structures.
1) Files are used to store, retrieve student and study center details.
The data is stored in Sequential manner in files. It is stored in binary form for faster retrieval of the data during search process.
2) Arrays
are used for program processing.
Advantages of using Arrays in this program :
a) Store of the similar data in sequential manner.
b) Easier Access.
TOP
Risk Factors:
1)Speed
The project is made in eCf language whereas the project is more or less a hardcore database project.
As the size of students will increase , the data size will also increase.
With the increase in the size of the database , search for a particular center will become slow.
2) Multiple Usage
The multiple usage of the database is not possible as there is no database engine being used.
All the data is saved in ascii format. In a Database package, the database engine takes care of these issue. Multiplier users can use the software
at the same time. The Database takes care of locking and conncurrency. This is a very big disadvantage as the number of students will be very large.
Single use of the software will make it highly inefficient.
******************************************************************************
******************************************************************************
by Pramod Kumar Mahapatra
/* SI - Student Information SCI - Study Center Information */
#include <stdio.h>
#include <conio.h>
#include <ctype.h>
#include <stdlib.h>
#include <string.h>
/* Defines here all the files are used in this program */
/* This is Student Information file */
#define SIFILE "SI.DAT"
/* This is Study Center Information file */
#define SCIFILE "SCI.DAT"
/* Record of the Student */
typedef struct {
/* Student's Roll Number(Max. no. of char is 9) */
char RollNumber[10];
/* Name of the Student(Max. no. of char is 30) */
char Name[31];
/* Program Code(Max. no. of char is 10) */
char ProgramCode[11];
/* Address of the Student(Max. no. of char is 30) */
char Address[31];
/* Place of residence of the Student(Max. no. of char is 15) */
char Place[16];
/* Medium(English/Hindi) of the course(Max. no. of char is 7) */
char Medium[8];
/* Region Code of the Student */
int RegionCode;
/* Study Center Code of the Student
(Which is preferance given by the Student) */
int StudyCenterCode;
} SI;
/* Record of the Study Center */
typedef struct {
/* Code of the Study Center */
int CenterCode;
/* Name of the Study Center(Max. no. of char is 30) */
char Name[31];
/* Address of the Study Center(Max. no. of char is 30) */
char Address[31];
/* Place of the Study Center(Max. no. of char is 15) */
char Place[16];
/* Capacity of the Study Center(Max not of Student can be studied */
int TotalCapacity;
} SCI;
/* Forward declaration of all the functions that are used in this program
*/
/* To diaplay Menu */
int Menu();
/* To find out total no. of student for a particular study center */
int TotalStudent(int StudyCenterCode);
/* Checks Availability of study center */
int CheckAvailability(int StudyCenterCode, int Capacity);
/* Gets the total capacity of a study center */
int GetStudyCenterCapacity(int StudyCenterCode);
/* If a study center is full then it searches
for next available nearest study center */
int CheckForOther(int RegionCode, char * Place);
/* Manages the Student Inforamtion */
void StudentInfo();
/* Manages the Study Center Information */
void StudyCenterInfo();
/* Accepts Students Information */
void GetStudentInfo(SI * Student);
/* Accepts Study Center Information */
void GetStudyCenterInfo(SCI * Study);
/* Adds Student Information to the File */
void AddStudentInfo(SI Student);
/* Adds Study Center Information to the File */
void AddStudyCenter(SCI Study);
/* Displays All the study center one by one */
void DisplayStudyCenter();
/* Application starts here */
void main(void) {
/* Variable for getting choice from the user */
int Choice;
/* Display menu to user till user wants to exit */
do {
/* Display the Menu and accept the choice */
Choice = Menu();
/* Take a decision based on user choice */
switch(Choice) {
/* If Choice is 1 */
case 1:
/* Manipulate the student information */
StudentInfo();
break;
/* If choice is 2 */
case 2:
/* Manipulate the study center information */
StudyCenterInfo();
break;
/* If choice is 3 */
case 3:
/* Do nothing */
break;
/* If choice other than 1 or 2 */
default:
/* Print an error message */
printf("\n\t\t\tInvalid Choice(Press any key to continue)");
/* Wait for a key press */
getch();
break;
}
} while(Choice != 3); /* If choice is 3 then come out */
}
TOP
/* Function to Manipulate Student Information */
void StudentInfo() {
/* Variable for getting user choice */
char Choice;
/* Record for Student */
SI Student;
/* Variable to hold availability of study center */
int Available;
/* Variable to hold availability of other study center */
int OtherStudyCenter;
/* Variable to store capacity of a study center */
int Capacity;
/* Clear the screen */
clrscr();
/* Print the Module name */
printf("\n\t\t\tAddition Module for Student Information\n");
/* Accept the user input for student information */
GetStudentInfo(&Student);
/* prompt to user 'Searching' */
printf("\n\t\tSearching for Study center availability ....");
/* Find the capacity of a study center */
Capacity = GetStudyCenterCapacity(Student.StudyCenterCode);
/* Check for availability of a study center */
Available = CheckAvailability(Student.StudyCenterCode, Capacity);
/* If not vailable */
if(!Available) {
/* Display this message in the screen */
printf("\n\t\tThis Study Center is full. Checking for other ...");
/* Check for other nearest study center */
OtherStudyCenter = CheckForOther(Student.RegionCode, Student.Place);
/* If all other study center are full for a particular region */
if(OtherStudyCenter <= 0) {
/* Display Error message and continue with the next operation */
printf("\n\t\tAll Study Center for this Region is full ...");
printf("\n\t\tPress any key to continue ...");
/* Wait for a key press */
getch();
/* Return to the parent function */
return;
}
/* Assign other study center to this student */
Student.StudyCenterCode = OtherStudyCenter;
/* Displa newly allocated study center */
printf("\n\t\tStudy Center allocated is %d", OtherStudyCenter);
}
/* Get user conformation to add student informatio to the File */
printf("\n\t\tAre u sure to add this information(Y/N): ");
/* Clear the standard in buffer */
fflush(stdin);
/* Get the user choice Y or N */
Choice = getchar();
/* I Y(yes) */
if(toupper(Choice) == 'Y') {
/* Add the student information to the File */
AddStudentInfo(Student);
}
}
/* Function to Manipulate Study Center Information */
void StudyCenterInfo() {
/* Variable to get user choice */
char Choice;
/* Record for the Study center */
SCI Study;
/* Clear the screen */
clrscr();
/* Display the Module Information to the user */
printf("\n\t\t\tAddition Module for Study Center\n");
/* Accept the Study center information */
GetStudyCenterInfo(&Study);
/* Prompt to this to user to accept conformation */
printf("\n\t\tAre u sure to add this information(Y/N): ");
/* Clear the standard in buffer */
fflush(stdin);
/* Get the user choice */
Choice = getchar();
/* Check for whether user has entered Y(yes) */
if(toupper(Choice) == 'Y') {
/* Add the Study center Inforamtion to the File */
AddStudyCenter(Study);
}
/* Display all the Study center */
DisplayStudyCenter();
}
/* Function to accept the student deails */
void GetStudentInfo(SI * Student) {
/* Accepts the Student Information */
printf("\n\tEnter Enrollment number: ");
fflush(stdin);
gets(Student->RollNumber);
printf("\n\tEnter Enter the Student Name: ");
fflush(stdin);
gets(Student->Name);
printf("\n\tEnter Program Code: ");
fflush(stdin);
gets(Student->ProgramCode);
printf("\n\tEnter Address of the Student: ");
fflush(stdin);
gets(Student->Address);
printf("\n\tEnter Place: ");
fflush(stdin);
gets(Student->Place);
printf("\n\tEnter Medium of study: ");
fflush(stdin);
gets(Student->Medium);
printf("\n\tEnter Region Code: ");
fflush(stdin);
scanf("%d", &Student->RegionCode);
printf("\n\tEnter Study Center Code: ");
fflush(stdin);
scanf("%d", &Student->StudyCenterCode);
}
/* Function to accept the Study center details */
void GetStudyCenterInfo(SCI * Study) {
/* Accepts the Study Center Information */
printf("\n\tEnter the Study Center Code: ");
fflush(stdin);
scanf("%d", &Study->CenterCode);
printf("\n\tEnter the Name of Study Center: ");
fflush(stdin);
gets(Study->Name);
printf("\n\tEnter the Address of Study Center: ");
fflush(stdin);
gets(Study->Address);
printf("\n\tEnter the Place of Study Center: ");
fflush(stdin);
gets(Study->Place);
printf("\n\tEnter the Total capacity of the Study Center: ");
fflush(stdin);
scanf("%d", &Study->TotalCapacity);
}
/* Function to display the Menu and accept the user choice */
int Menu() {
/* Variable for getting the user choice */
int Choice;
/* Clear the screen */
clrscr();
/* Display the Menu */
printf("\n\n\n\n\n\t\t\t1 - Student Information");
printf("\n\n\t\t\t2 - Study Center Information");
printf("\n\n\t\t\t3 - Exit");
/* Display for user choice */
printf("\n\n\t\t\tEnter your Choice(1 or 2 or 3): ");
/* Clear the standard in buffer */
fflush(stdin);
/* Accept the user choice */
scanf("%d", &Choice);
/* Return the user choice */
return Choice;
}
/* Function to count no. of student attached to a study center */
int TotalStudent(int StudyCenterCode) {
/* Variable to store total no. student for a study center */
int Count = 0;
/* Record for Student Information */
SI Student;
/* File Pointer */
FILE * fp;
/* Open Student Information file in read and binary mode */
fp = fopen(SIFILE, "rb");
/* If file could not open successfuly */
if(fp == NULL)
return 0;
/* Read the first record */
fread(&Student, sizeof(SI), 1, fp);
/* Repeat this till end of the file */
while(!feof(fp)) {
TOP
/* I f a student belongs to this study
center then increament the count */
if(Student.StudyCenterCode == StudyCenterCode)
Count++;
/* Read the Next Record in the File */
fread(&Student, sizeof(SI), 1, fp);
}
/* Close the File */
fclose(fp);
/* Return the Total no. of student for a particular study center */
return Count;
}
/* Function to Add Study Center Information */
void AddStudyCenter(SCI Study) {
/* File pointer */
FILE * fp;
/* Open the Study Center Information File in append and binary mode */
fp = fopen(SCIFILE, "ab");
/* Write a record to the File */
fwrite(&Study, sizeof(SCI), 1, fp);
/* Close the File */
fclose(fp);
}
/* Function to display all study center */
void DisplayStudyCenter() {
/* Record for Study Center Information */
SCI Study;
/* File pointer */
FILE * fp;
/* Open the Study Center Information file */
fp = fopen(SCIFILE, "rb");
/* If unable to open that file */
if(fp == NULL) {
/* Display error message */
printf("\n\t\tThere is no record to display");
printf("\n\t\tPress any key to continue ...");
/* Wait for a key press */
getch();
/* Return to parent function */
return;
}
/* Read the first record */
fread(&Study, sizeof(SCI), 1, fp);
/* Repeat this till end of the file */
while(!feof(fp)) {
/* Clear the screen */
clrscr();
/* Display the Record in the screen */
printf("\n\n\tStudy Center Code: %d", Study.CenterCode);
printf("\n\n\tName of Study Center: %s", Study.Name);
printf("\n\n\tAddress of Study Center: %s", Study.Address);
printf("\n\n\tPlace of Study Center: %s", Study.Place);
printf("\n\n\tTotal capacity of the Study Center: %d",
Study.TotalCapacity);
printf("\n\n\tPress any key to display next record ...");
/* Wait for a key press */
getch();
/* Read the Next Record */
fread(&Study, sizeof(SCI), 1, fp);
}
/* Close the file */
fclose(fp);
}
/* Function to add the Student information to the File */
void AddStudentInfo(SI Student) {
/* File pointer */
FILE * fp;
/* Open the Student Information file in append and binary mode */
fp = fopen(SIFILE, "ab");
/* Write Student Information to the File */
fwrite(&Student, sizeof(SI), 1, fp);
/* Close the file */
fclose(fp);
}
/* Function to get Study Center Capacity */
int GetStudyCenterCapacity(StudyCenterCode) {
/* File pointer */
FILE * fp;
/* Record for Study center */
SCI Study;
/* Open the Study Center Information File in read and Binary mode */
fp = fopen(SCIFILE, "rb");
/* If unable to open the file */
if(fp == NULL)
return 0;
/* Read The first record */
fread(&Study, sizeof(SCI), 1, fp);
/* Repeat this till end of the file */
while(!feof(fp)) {
/* If searching matches */
if(Study.CenterCode == StudyCenterCode) {
/* Close the file */
fclose(fp);
/* Return the study center capacity to the parent function */
return Study.TotalCapacity;
}
/* Read the next record */
fread(&Study, sizeof(SCI), 1, fp);
}
/* Close the File */
fclose(fp);
/* Return that study center not found */
return 0;
}
/* Function to check availability of study center */
int CheckAvailability(int StudyCenterCode, int Capacity) {
/* Variable to store total no. of student for a study center */
int Count = 0;
/* File pointer */
FILE * fp;
/* Record for Student Information */
SI Student;
/* If capacity is below 1 then */
if(Capacity <= 0)
return 0;
/* Open the Student Information File in read and Binary mode */
fp = fopen(SIFILE, "rb");
/* unable to open this file */
if(fp == NULL)
return 1;
TOP
/* Read the First record in the databse */
fread(&Student, sizeof(SI), 1, fp);
/* Repeat this till end of the file */
while(!feof(fp)) {
/* If any student belongs to this study center */
if(Student.StudyCenterCode == StudyCenterCode)
Count++;
/* Read the next Record in the File */
fread(&Student, sizeof(SI), 1, fp);
}
/* Close the file */
fclose(fp);
/* Return the availability based on condition */
return Count < Capacity;
}
/* Function for checking nearest Study Center */
int CheckForOther(int RegionCode, char * Place) {
/* File pointer */
FILE * fp;
/* Record for Study Center */
SCI Study;
/* variable to store availability */
int Available;
/* Open the Study Center Information File in Read and Binary mode */
fp = fopen(SCIFILE, "rb");
/* If unable to open the file */
if(fp == NULL)
return 0;
/* Read the first record from the file */
fread(&Study, sizeof(SCI), 1, fp);
/* Repeat this till end of the file */
while(!feof(fp)) {
/* I student place matches with the study center's Place */
if(!strcmpi(Place, Study.Place)) {
/* Check for availability for a study center */
Available = CheckAvailability(Study.CenterCode,
Study.TotalCapacity);
/* If available */
if(Available) {
/* Close the file */
fclose(fp);
/* Return the Study Center code to parent function */
return Study.CenterCode;
}
}
/* Read the next record from the file */
fread(&Study, sizeof(SCI), 1, fp);
}
/* Go to the bigining of the file */
rewind(fp);
/* Read the first record from the file */
fread(&Study, sizeof(SCI), 1, fp);
/* Repeat till end of the file */
while(!feof(fp)) {
/* If this study center belongs to same region */
if(RegionCode == (Study.CenterCode/100)) {
/* Check for availability for a study center */
Available = CheckAvailability(Study.CenterCode,
Study.TotalCapacity);
/* If available */
if(Available) {
/* Close the file */
fclose(fp);
/* Retrun the Study Center code to the parent function */
return Study.CenterCode;
}
}
/* Read the next record from the file */
fread(&Study, sizeof(SCI), 1, fp);
}
/* Close the file */
fclose(fp);
/* Return there is no study center for this region */
return 0;
}
******************************************************************************
******************************************************************************
Sonylal
--------------------------------------------------------------------------------
#include<stdio.h>
#include<conio.h>
#include<string.h>
struct student
{
int rno;
char snm[10];
char hnm[10];
char place[10];
int coid;
int ctridp;
int ctrida;
char regctr[10];
}st;
struct center
{
int ctrid;
char ctrnm[10];
char place[10];
char regctr[10];
}ct;
struct seats
{
int ctrid;
int coid;
int nofsts;
int stsfld;
}ss;
FILE *sts,*ctr,*stud;
int findcenter(int);
void main()
TOP
{
int count,flag=0,opt,choice;
struct student st1;
struct seats ss1;
struct center ct1;
while(1)
{
clrscr();
printf("\n1 Center");
printf("\n2 Seats");
printf("\n3 Students");
printf("\n4 Display");
printf("\n5 Exit");
printf("\nEnter Your Choice : ");
scanf("%d",&opt);
switch(opt)
{
case 1:
{
printf("Enter Center ID :");
scanf("%d",&ct.ctrid);
printf("Enter Center Name :");
scanf("%s",&ct.ctrnm);
printf("Enter Place :");
scanf("%s",&ct.place);
printf("Enter Regional Center :");
scanf("%s",&ct.regctr);
ctr=fopen("center.dat","a+");
fwrite(&ct,sizeof(ct),1,ctr);
fclose(ctr);
break;
}
case 2:
{
printf("Enter Center ID :");
scanf("%d",&ss.ctrid);
printf("Enter Course ID :");
scanf("%d",&ss.coid);
printf("Enter No of Seats :");
scanf("%d",&ss.nofsts);
ss.stsfld=0;
sts=fopen("seats.dat","a+");
fwrite(&ss,sizeof(ss),1,sts);
fclose(sts);
break;
}
case 3:
{
printf("Enter Roll No :");
scanf("%d",&st.rno);
printf("Enter Name :");
scanf("%s",&st.snm);
printf("Enter House name :");
scanf("%s",&st.hnm);
printf("Enter Place :");
scanf("%s",&st.place);
printf("Enter Course Id :");
scanf("%d",&st.coid);
printf("Enter Center Preffered:");
scanf("%d",&st.ctridp);
printf("Enter Regional Center :");
scanf("%s",&st.regctr);
sts=fopen("seats.dat","r+");
stud=fopen("student.dat","a+");
flag=findcenter(st.ctridp);
if(flag!=1)
{
ctr=fopen("center.dat","a+");
fseek(ctr,0,0);
while(!feof(ctr))
{
fread(&ct,sizeof(ct),1,ctr);
if(strcmpi(ct.regctr,st.regctr)==0)
{
fseek(sts,0,0);
flag=findcenter(ct.ctrid);
if(flag==1)break;
}
}
}
fclose(stud);
fclose(ctr);
fclose(sts);
break;
}
case 4:
{
printf("\n1-Student Details\n2-Center Details\n3-Seat Deatails");
printf("\nEnter Your Choice :");
scanf("%d",&choice);
switch(choice)
{
case 1:
{
stud=fopen("student.dat","r");
fread(&st1,sizeof(st1),1,stud);
printf("\nÚÄÄÄÄÂÄÄÄÄÄÄÄÄÄÄÄÂÄÄÄÄÄÄÄÄÄÄÄÂÄÄÄÄÄÄÄÄÄÄÂÄÄÄÄÂÄÄÄÄÂÄÄÄÄ¿");
printf("\n³ Rno³ Name ³House Name ³ Place ³C-ID³C-PR³C-AL³");
while(!feof(stud))
{
printf("\nÃÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÅÄÄÄÄÅÄÄÄÄ´");
printf("\n³%4d³%11s³%11s³%10s³%4d³%4d³%4d³",st1.rno,st1.snm,st1.hnm, st1.place,st1.coid,st1.ctridp,st1.ctrida);
fread(&st1,sizeof(st1),1,stud);
}
printf("\nÀÄÄÄÄÁÄÄÄÄÄÄÄÄÄÄÄÁÄÄÄÄÄÄÄÄÄÄÄÁÄÄÄÄÄÄÄÄÄÄÁÄÄÄÄÁÄÄÄÄÁÄÄÄÄÙ");
fclose(stud);
break;
}
case 2:
{
ctr=fopen("center.dat","r");
fread(&ct1,sizeof(ct1),1,ctr);
printf("\nÚÄÄÄÄÄÄÄÄÄÄÄÂÄÄÄÄÄÄÄÄÄÄÄÄÂÄÄÄÄÄÄÄÄÄÄÂÄÄÄÄÄÄÄÄÄÄÄÄ¿");
printf("\n³ Center ID ³ Center Name³ Place ³ Reg. Center³");
while(!feof(ctr))
{
printf("\nÃÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄ´");
printf("\n³%11d³%12s³%10s³%12s³",ct1.ctrid,ct1.ctrnm,ct1.place,ct1.regctr);
fread(&ct1,sizeof(ct1),1,ctr);
}
printf("\nÀÄÄÄÄÄÄÄÄÄÄÄÁÄÄÄÄÄÄÄÄÄÄÄÄÁÄÄÄÄÄÄÄÄÄÄÁÄÄÄÄÄÄÄÄÄÄÄÄÙ");
fclose(ctr);
break;
}
case 3:
{
sts=fopen("seats.dat","r");
fread(&ss1,sizeof(ss1),1,sts);
printf("\nÚÄÄÄÄÄÄÄÄÄÄÄÂÄÄÄÄÄÄÄÄÄÄÄÂÄÄÄÄÄÄÄÄÄÄÂÄÄÄÄÄÄÄÄÄÄÄÄ¿");
printf("\n³ Center ID ³ Course ID ³Total Seat³Seats Filled³");
while(!feof(sts))
{
printf("\nÃÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄ´");
printf("\n³%11d³%11d³%10d³%12d³",ss1.ctrid,ss1.coid,ss1.nofsts,ss1.stsfld);
fread(&ss1,sizeof(ss1),1,sts);
}
printf("\nÀÄÄÄÄÄÄÄÄÄÄÄÁÄÄÄÄÄÄÄÄÄÄÄÁÄÄÄÄÄÄÄÄÄÄÁÄÄÄÄÄÄÄÄÄÄÄÄÙ");
fclose(sts);
break;
}
}
break;
}
case 5:
{
exit(0);
break;
}
}
getch();
}
}
int findcenter(int ctrid)
{
int count=0;
int flag=0;
while(!feof(sts))
{
fread(&ss,sizeof(ss),1,sts);
count++;
if(ss.ctrid==ctrid && ss.coid==st.coid)
{
if(ss.nofsts>ss.stsfld)
{
ss.stsfld++;
st.ctrida=ss.ctrid;
fwrite(&st,sizeof(st),1,stud);
fseek(sts,-8,1);
fwrite(&ss,sizeof(ss),1,sts);
flag=1;
break;
}
}
}
return(flag);
} |