bare bones grades program
Code:
1 /*****************************************************
2 * A Program To Manage Grades *
3 * written by: stormy *
4 * 9/1/05 *
5 ******************************************************/
6 #include <stdio.h>
7 #include <stdlib.h>
8 #include <string.h>
9 #include <math.h>
10
11 #define BUFFER 100
12
13 char name[BUFFER]; /* students name */
14 char assignment[BUFFER]; /* assignment name */
15 char *Nassignment[BUFFER][10]; /* array to hold assignment names */
16 int num_grades; /* number of grades */
17 int grade; /* actuall grade number */
18 int count = 0, i = 0; /* counters */
19 int ngrade[BUFFER]; /* array to hold grades */
20
21 int main()
22 {
23
24 //////// TAKE IN INITIAL INFO ////////
25 printf("Student name:");
26 scanf("%s", name);
27
28 //////// BEGIN LOOP FOR GRADES ////////
29
30 printf("How many grades?:");
31 scanf("%d", &num_grades);
32
33 while (i < num_grades) {
34
35 printf("Assignment:");
36 scanf("%s", assignment);
37 Nassignment[count][count] = assignment;
38 printf("Grade:");
39 scanf("%d", &grade);
40 ngrade[count] = grade;
41 ++count;
42 ++i;
43 }
44
45 //////// DO THE MATH ////////
46 int i = 0;
47 int k = 1;
48 int result = 0;
49
50 while (i < count) {
51 result = ngrade[i] + ngrade[k];
52 ++i;
53 ++k;
54 }
55
56 //////// OUTPUT FORMATTED RESULTS ////////
57 i = 0;
58 printf("\t\tStudent Name: %s\n", name);
59 printf("=====================================================\n");
60 while (i < count) {
61 printf("%s\t\t%d\n", *Nassignment[i], ngrade[i]);
62 i++;
63 }
64 printf("Final Average:%d\n", result / count);
65 printf("=====================================================\n");
66
67 return(0);
68 }
The *main* problem I'm having is getting the result correct. I really just need some good eyes and suggestions, maybe a couple of links. Also assignment is borked.