PROGRAM 18
// FILENAME: PROG18.CPP // THIS PROGRAM KEEPS TRACK OF 10 STUDENTS' NAMES, AGES, LETTER GRADES, AND // IQ'S USING A STRUCTURE. #include #include #include #include #include struct student_record { char name [25]; int age; char grade; int iq; }; get_copyright (); change_screen (int x1, int x2, int y1, int y2, int c1, int c2, int c3, int c4); input_records (struct student_record student [10]); print_records (struct student_record student [10]); main () { struct student_record student [10]; get_copyright (); input_records (student); print_records (student); return 0; } get_copyright () { char pause; change_screen (30, 7, 52, 15, 13, 8, 12, 0); #include gotoxy (6, 7); cprintf (" PROG18.CPP"); gotoxy (20, 8); pause = getch (); return 0; } change_screen (int x1, int x2, int y1, int y2, int c1, int c2, int c3, int c4) { textbackground (c1); window (1, 1, 80, 25); clrscr (); textbackground (c2); window (x1 + 2, x2 + 1, y1 + 2, y2 + 1); clrscr (); textbackground (c3); textcolor (c4); window (x1, x2, y1, y2); clrscr (); return 0; } input_records (struct student_record student [10]) { int count; char temporary [25]; change_screen (14, 7, 66, 15, 1, 8, 3, 4); for (count = 0; count < 10; count++) { clrscr (); gotoxy (3, 2); cprintf ("ENTER STUDENT'S NAME. "); gets (student [count].name ); gotoxy (3, 4); cprintf ("ENTER STUDENT'S AGE. "); gets (temporary); student [count].age = atoi (temporary); gotoxy (3, 6); cprintf ("ENTER STUDENT'S GRADE. "); student [count].grade = getche (); gotoxy (3, 8); cprintf ("ENTER STUDENT'S IQ. "); gets (temporary); student [count].iq = atoi (temporary); } return 0; } print_records (struct student_record student [10]) { char pause; int count; cout.setf (ios :: showpoint); change_screen (10, 4, 70, 21, 13, 8, 12, 0); gotoxy (2, 2); cprintf (" 10 STUDENT'S RECORDS"); gotoxy (2, 4); cprintf ( " STUDENT NAME AGE GRADE IQ"); for (count = 0; count < 10; count++) { gotoxy (3, count + 6); cprintf ("%s", student [count].name); gotoxy (32, count + 6); cprintf ("%i", student [count].age); gotoxy (45, count + 6); cprintf ("%c", student [count].grade); gotoxy (58, count + 6); cprintf ("%i", student [count].iq); } gotoxy (3, 17); cprintf ("PRESS ENTER KEY TO CONTINUE. "); pause = getch (); return 0; } // FILENAME: COPY.H // SEE PROGRAM 7. // OUTFILE: PROG18.OUT ENTER STUDENT'S NAME. anthony f. ortiz ENTER STUDENT'S AGE. 30 ENTER STUDENT'S GRADE. a ENTER STUDENT'S IQ. 200 10 STUDENT'S RECORDS STUDENT NAME AGE GRADE IQ anthony 30 a 200 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 PRESS ENTER KEY TO CONTINUE.
BACK TO CIS162 PAGE.