J
jjmillertime
I need help with an assignment in my C programming class. My teacher
sucks and basically has told me that anything i need to know is in the
book, which is fine but she hasn't taught us much of anything and i've
been having a lot of problems with this program, so i scrapped it and
hopefully can get some help on here. any help would be great.
This is the assignment
Emphasis of this program is on arrays.
Write a program that will read in grades, calculates the average grade
and shows how much each score differs from the average.
Input: Prompt the user for input grades. Your program should read in
all the grades supplied by the user, but retain only those grades that
are in the range 0 to 100 (both values inclusive).
Your program should keep reading the grades from the keyboard until it
encounters EOF. You may store the grades as integers. You may assume
that no more than 80 grades will be supplied at any given time. Thus,
you may set the array size to 80. Use a macro for this purpose.
Output: Print the grades in a neatly formatted fashion as displayed
below (see 'Sample Runs' below)
Your program should terminate only when the user supplies EOF ( Ctrl D
- on UNIX)
Your program should be split into component functions.
Ensure that you have your Name, Class (Ex. cs211 - Day), Assignment
number, Description at the beginning of your program. Also, include
comments at appropriate positions in the program.
Your program should be indented neatly. DO NOT USE tabs (3 spaces
would be ideal)
Variable names should be descriptive.
Your program should be split up into several files as explained below:
o prog4.c : This will hold the main function
o prog4Fns.c: This file will consist of the component functions
o prog4.h: Header file for your program
You will need to #include your header file in both the source (.c)
files
DO NOT #include ONE SOURCE FILE INSIDE ANOTHER.
Compile your program with the -Wall option as follows:
o gcc -Wall prog4.c prog4Fns.c -o prog4
Hand in the files prog4.c prog4Fns.c electronically. Use the command:
~cs211d/bin/handin 4 prog4.c prog4Fns.c prog4.h
DO NOT e-mail the program to me. It will be deleted.
Some sample runs of the program:
Compile:
bugs> gcc -Wall prog4.c prog4Fns.c -o prog4
NOTE: In the following 'runs' blue font implies the lines are output
by the program, black font implies items typed in by the user.
In Run1, Run2, Run3 - we have no output displayed because the input
supplied does not consist of a single valid grade.
Further, note that the average is printed ONLY ONCE (ON THE FIRST
LINE)
Run1:
kira> prog4
Enter grades separated by spaces (min: 0, max: 100 ):
No grades entered. Exiting program
kira>
Run2:
kira> prog4
Enter grades separated by spaces (min: 0, max: 100 ): -24 -45 -93
-123
No valid grades entered. Exiting program
kira>
Run3:
kira> prog4
Enter grades separated by spaces (min: 0, max: 100 ): a
Invalid input; try again:
b
Invalid input; try again:
c
Invalid input; try again:
No grades entered. Exiting program
kira>
Run4:
kira> prog4
Enter grades separated by spaces (min: 0, max: 100 ): 23 -34 123 0
100
Discarding the 2 invalid grade(s) entered
Grade Average Deviation from Average
===================================================
23 41.00 -18.00
0 -41.00
100 59.00
kira>
Run5:
kira> prog4
Enter grades separated by spaces (min: 0, max: 100 ): 98 93 77
24 90
99
45
-123
12345
0
100
A
Invalid input; try again:
87
Discarding the 2 invalid grade(s) entered
Grade Average Deviation from Average
===================================================
98 71.30 26.70
93 21.70
77 5.70
24 -47.30
90 18.70
99 27.70
45 -26.30
0 -71.30
100 28.70
87 15.70
kira>
Run6:
kira> prog4
Enter grades separated by spaces (min: 0, max: 100 ): 98
99
98
97
98
Grade Average Deviation from Average
===================================================
98 98.00 0.00
99 1.00
98 0.00
97 -1.00
98 0.00
kira>
sucks and basically has told me that anything i need to know is in the
book, which is fine but she hasn't taught us much of anything and i've
been having a lot of problems with this program, so i scrapped it and
hopefully can get some help on here. any help would be great.
This is the assignment
Emphasis of this program is on arrays.
Write a program that will read in grades, calculates the average grade
and shows how much each score differs from the average.
Input: Prompt the user for input grades. Your program should read in
all the grades supplied by the user, but retain only those grades that
are in the range 0 to 100 (both values inclusive).
Your program should keep reading the grades from the keyboard until it
encounters EOF. You may store the grades as integers. You may assume
that no more than 80 grades will be supplied at any given time. Thus,
you may set the array size to 80. Use a macro for this purpose.
Output: Print the grades in a neatly formatted fashion as displayed
below (see 'Sample Runs' below)
Your program should terminate only when the user supplies EOF ( Ctrl D
- on UNIX)
Your program should be split into component functions.
Ensure that you have your Name, Class (Ex. cs211 - Day), Assignment
number, Description at the beginning of your program. Also, include
comments at appropriate positions in the program.
Your program should be indented neatly. DO NOT USE tabs (3 spaces
would be ideal)
Variable names should be descriptive.
Your program should be split up into several files as explained below:
o prog4.c : This will hold the main function
o prog4Fns.c: This file will consist of the component functions
o prog4.h: Header file for your program
You will need to #include your header file in both the source (.c)
files
DO NOT #include ONE SOURCE FILE INSIDE ANOTHER.
Compile your program with the -Wall option as follows:
o gcc -Wall prog4.c prog4Fns.c -o prog4
Hand in the files prog4.c prog4Fns.c electronically. Use the command:
~cs211d/bin/handin 4 prog4.c prog4Fns.c prog4.h
DO NOT e-mail the program to me. It will be deleted.
Some sample runs of the program:
Compile:
bugs> gcc -Wall prog4.c prog4Fns.c -o prog4
NOTE: In the following 'runs' blue font implies the lines are output
by the program, black font implies items typed in by the user.
In Run1, Run2, Run3 - we have no output displayed because the input
supplied does not consist of a single valid grade.
Further, note that the average is printed ONLY ONCE (ON THE FIRST
LINE)
Run1:
kira> prog4
Enter grades separated by spaces (min: 0, max: 100 ):
No grades entered. Exiting program
kira>
Run2:
kira> prog4
Enter grades separated by spaces (min: 0, max: 100 ): -24 -45 -93
-123
No valid grades entered. Exiting program
kira>
Run3:
kira> prog4
Enter grades separated by spaces (min: 0, max: 100 ): a
Invalid input; try again:
b
Invalid input; try again:
c
Invalid input; try again:
No grades entered. Exiting program
kira>
Run4:
kira> prog4
Enter grades separated by spaces (min: 0, max: 100 ): 23 -34 123 0
100
Discarding the 2 invalid grade(s) entered
Grade Average Deviation from Average
===================================================
23 41.00 -18.00
0 -41.00
100 59.00
kira>
Run5:
kira> prog4
Enter grades separated by spaces (min: 0, max: 100 ): 98 93 77
24 90
99
45
-123
12345
0
100
A
Invalid input; try again:
87
Discarding the 2 invalid grade(s) entered
Grade Average Deviation from Average
===================================================
98 71.30 26.70
93 21.70
77 5.70
24 -47.30
90 18.70
99 27.70
45 -26.30
0 -71.30
100 28.70
87 15.70
kira>
Run6:
kira> prog4
Enter grades separated by spaces (min: 0, max: 100 ): 98
99
98
97
98
Grade Average Deviation from Average
===================================================
98 98.00 0.00
99 1.00
98 0.00
97 -1.00
98 0.00
kira>