Example #1
0
void compute_histogram(int bins[], int n_students, float grades[])
{
        float min = minimum_of(n_students, grades);
        float max = maximum_of(n_students, grades);
        float range = max - min;
        float bin_size = range / N_BINS;

        for (int i = 0; i < N_BINS; ++i)
                bins[i] = 0;

        for (int i = 0; i < n_students; ++i) {
                int bin_id = (grades[i] - min) / bin_size;
                if (bin_id == N_BINS)
                        bin_id = N_BINS-1;
                bins[bin_id]++;
        }
}
Example #2
0
int main(int argc, char *argv[])
{
	int result;
	int a, b;

	if (argc != 3) {
		fprintf(stderr, "kullanim: max <sayi1> <sayi2>\n");
		exit(1);
	}

	a = atoi(argv[1]);
	b = atoi(argv[2]);

	result = maximum_of(a, b);
	printf("%d ve %d'nin büyüğü: %d\n", a, b, result);

	return 0;
}
Example #3
0
int main(void)
{		
	float *grades;//grades is a float pointer that holds grades of students.
        int *n;
	*n=0;//it is a copy of number of students.Also,when I write int *n=0,I have segmentation fault.Therefore,I did this one.
        grades = load_grades(n);//we call the function load_grades and it reads from the file(ceng211_midterm.txt)
        printf("Number of students is %d\n", *n);//we write the number of students.
        float min = minimum_of(n, grades);//the other rows have a few changes.
        printf("Minimum is %.2f\n", min);
        float max = maximum_of(n, grades);
        printf("Maximum is %.2f\n", max);
        float average = average_of(n, grades);
        printf("Average is %.2f\n", average);

        printf("Letter grades:\n");
        for (int i = 0; i < (*n); ++i) {
                printf("%6.2f -> %s\n", grades[i], letter_grade_for((grades+i), average));
        }  
		
        return EXIT_SUCCESS;
}