Need help with the below assignment. Please attach the output at the end. You ar
ID: 660592 • Letter: N
Question
Need help with the below assignment. Please attach the output at the end.
You are given a data file containing information about students. Design, code and test a
C program that reads the file, creates an array of student structures, then processes the
array to output many different reports.
Format of the student structure and data file
Format of the student structure is:
? first name - string, 7 data chars max
? initial - string, 1 data char max
? last name - string, 9 data chars max
? address - nested structure containing:
o street - string, 16 data chars max
o city - string, 11 data chars max
o state - string, 2 data chars max
o zip - string, 5 data chars max
? age - integer
? gpa - double
This information will be read by the program from the
Explanation / Answer
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
//below are amount of room for the info in the structs
#define FIRSTNAME 7
#define MIDINITIAL 1
#define LASTNAME 9
#define STREET 16
#define CITY 11
#define STATE 2
#define ZIP 5
#define AGE 3
#define GPA 5//includes newline space
#define STUDENTNUMBER 25//avg # of students in a class
#define MAX 100
void sortIntArray(int arr[], int num);//probably orders GPA
void strsub(char dataline[], char s2[], int start, int length);
typedef struct{
char street[STREET + 1];//allowed to +1?
char city[CITY + 1];
char state[STATE + 1];
char zip[ZIP + 1];
}Address;//first letter caps
typedef struct{
char firstname[FIRSTNAME + 1];//+1 for /0
char midinitial[MIDINITIAL + 1];
char lastname [LASTNAME + 1];
//char street[STREET];
//char city[CITY];
//char state[STATE];
//char zip[ZIP]; make this + upper comments a nested struct
Address stuaddress;
int age;//keep at natural datatype then in strsub read into temp string local to f() then convert using atoi/atof
double gpa;
}Studentinfo;
/*first name - string, 7 data chars max
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.