Write a C Program to create a structured data file named
Student.dat to store the roll no, name
and course.
Provide following functions:
1. Accept the values from the user using structure
variables. Store the contents in a file.
2. Display the file.
3. The user should be able to add new records to the
existing file. And display the new file.
Answer Posted / muklesh kumr
#include <stdio.h>
#include <ctype.h>
struct Student
{
int ID;
char LastName[32];
char FirstName[32];
int DateOfBirth; // This could be of the form YYYYMMDD. For example someone born on December 21st, 1990 would have a value of 19901221
char Address[32];
char TelephoneNumber[11]; // a 10-digit string
char ProgramPursued[32];
};
char GetUserOption()
{
char option = 'I'; // 'I' for Invalid
while(option == 'I')
{
// Print the menu items
printf("\n");
printf("Choose one of the following options:\n[u]pdate [P]rint [S]earch [E]xit\n");
scanf("%c", &option);
switch(toupper(option))
{
case 'U':
case 'P':
case 'S':
case 'E':
break;
default:
option = 'I';
break;
}
}
return option;
}
// students must hold 10 students
void LoadStudents(Student students[])
{
// TODO: load students from file
}
// students must hold 10 students
void SaveStudents(Student students[])
{
// TODO: save students to file
}
int main()
{
Student students[10];
int looping = 1;
// Load the students from the file
LoadStudents(students);
// Loop until exit
while(looping)
{
char option = GetUserOption();
switch(option)
{
case 'U':
// TODO: Let the user update a record
break;
case 'P':
// TODO: Print the students to the screen
break;
case 'S':
// TODO: Let the user search for a student
break;
case 'E':
looping = 0; // exit the loop
break;
}
}
// Save the students to the file
SaveStudents(students);
return 0;
| Is This Answer Correct ? | 73 Yes | 64 No |
Post New Answer View All Answers
What is computer-based information system (CBIS) mean?
could you provide me the information regarding UNIVESAL WORK LIST(UWL)?this question is regarding SAP EP.
I didn't see any category for Project Management. What are the activities, documents; how to plan, schedule and monitor tasks, statuses, people...?
How retrive the deleted file frm UAT by doing migration in SAP BO 4.0
What id the meaning of MIS ? MIS nasure, charactersitcs, purpose ? how can the leanr about them ?
purpose of assigning Field Status Variant to Company code??
What are the practices you follow for closing a project and meeting the conditions required to establish closure?
In SAP Business Objects XI R3.1,4.0 Central Configuration Manager is down means what we have to do?
How to Cancel SAP PO against Fix transport?
What unique experience or qualifications separate you from other candidates?
From where I should start to prepare for cat?
7. (a) How do you implement internal controls in IT systems? (b) How to design internal controls over financial reporting, when financial reporting is performed totally from the software application? Explain briefly the major points. (c) What are the additional controls needed, when the software interfaces are webbased? Explain the materiality of the payroll processing functions to be performed by webinterfaces from the control perspective.
If you are a team lead in any IT company, and two employees are under your supervision. If one employee is good and other cannot behave professionally and personally, then how will you handle this situation?
why u choose mba after bca?
what do you mean by "Closures with help of Top Management and Colleagues"