Πρόγραμμα για το θέμα 4: βαθμολογία

#include <stdio.h>

/*
 * Print a number 0-10 as a word
 */
void
print_grade(int g)
{
	switch (g) {
	case 0:
		printf("μηδέν\n");
		break;
	case 1:
		printf("ένα\n");
	/* ... */
	case 10:
		printf("δέκα\n");
		break;
	}
}

main()
{
	int exercise, exam, grade;
	int count, sum;

	count = sum = 0;
	for (;;) {
		scanf("%d %d", &exercise, &exam);
		if (exercise == -1 && exam == -1)
			break;
		if (exercise >= 5 && exam >= 5)
			grade = 0.8 * exercise + 0.2 * grade;
		else if (exercise < exam)
			grade = exercise;
		else
			grade = exam;
		print_grade(grade);
		count++;
		sum = sum + grade;
	}
	printf("M.O. = ");
	print_grade(sum / grade);
}