Created
April 13, 2012 02:46
-
-
Save Xe/2373158 to your computer and use it in GitHub Desktop.
Lab 3
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <stdlib.h> | |
#include <string.h> | |
#define ASSGN 7 | |
#define QUIZ 8 | |
#define EXAMS 2 | |
#define FINAL 1 | |
#define NAME 100 | |
void fillArray(int, int[]); | |
void printAra(int, int[]); | |
double average(int, int[]); | |
double weightedGrade(double, int); | |
int main(int argc, char** argv) { | |
int assignments[ASSGN]; | |
int quizzes[QUIZ]; | |
int exams[EXAMS]; | |
int final[FINAL]; | |
char name[NAME]; | |
fgets(name, NAME, stdin); | |
fillArray(ASSGN, assignments); | |
fillArray(QUIZ, quizzes); | |
fillArray(EXAMS, exams); | |
fillArray(FINAL, final); | |
printf("%s", name); | |
//printAra(ASSGN, assignments); | |
//printAra(QUIZ, quizzes); | |
//printAra(EXAMS, exams); | |
//printAra(FINAL, final); | |
printf("Avg of assignments: %3.2f\n", average(ASSGN, assignments)); | |
printf("Avg of quizzes: %3.2f\n", average(QUIZ, quizzes)); | |
printf("Avg of exams: %3.2f\n", average(EXAMS, exams)); | |
printf("Final score %3.2f\n", (double)final[0]/100); | |
printf("this is a boring stub\n"); | |
return 0; | |
} | |
void fillArray(int count, int array[]) { | |
for (int i = 0; i < count; i++) { | |
//printf("Testing %d ", i); | |
fscanf(stdin, "%i", &array[i]); | |
} | |
} | |
void printAra(int count, int ara[]) { | |
for (int i = 0; i < count; i++) { | |
printf("%d ", ara[i]); | |
} | |
printf("\n"); | |
} | |
double average(int count, int array[]) { | |
double val = 0.0; | |
for (int i = 0; i < count; i++) { | |
val = val + array[i]; | |
} | |
val = val / count; | |
return val; | |
} | |
double weightedGrade(double perc, int weight) { | |
return 0.0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment