Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I\'m trying to also making it display seniors names age >65 JONES and JOHNSON an

ID: 3660123 • Letter: I

Question


I'm trying to also making it display seniors names age >65 JONES and JOHNSON

and a header with CHildren 18 and older which would be michaels,mitchel and fredickson

------------------------------------------------------------------------------------

create a test file called bio.txt

// the file will have the following format:

// lastname age

// lastname age

// ...

// read this file and create two arrays

// one array should contain the last name of all seniors (age >= 65)

// the other array should contain the last name of all children (age < 18)

// print out both arrays

// example:

// jones 84

// michaels 16

// fredrickson 22

// mitchell 7

// franklin 45

// johnson 77

// the result would be:

// seniors:

// jones

// johnson

// children:

// michaels

// mitchell


Explanation / Answer

#include #include #include int main(){ FILE *fp; fp=fopen("bio.txt","r"); char temp; int i=0; char senior[100][100],child[100][100],name[100]; int seniorage[100],childage[100],age=0; int flag_senior=0,flag_child=0,count_senior=0,count_child=0,flag=0; while(fscanf(fp,"%c",&temp)!=EOF){ //fscanf(fp,"%c",&temp); if(temp>='0' && temp=65){ strcpy(senior[count_senior],name); seniorage[count_senior]=age; flag_senior=1; } if(age