Beispiel #1
0
int main()
{
    struct xrec * first;
    struct xrec temp;
    FILE * infile = fopen("data.txt", "r");
    
    // Basic intialization to known values
    first = NULL;

    while (fscanf(infile, "%10s %11s %c %lf %lf %lf %lf", temp.name,
                                                          temp.ssn,
                                                          &temp.g,
                                                          &temp.h,
                                                          &temp.q,
                                                          &temp.m,
                                                          &temp.f) != EOF)
    {
        temp.name[10] = '\0';

        first = prepend_to_list(first, temp);
    }

    fclose(infile);

    compute_grade(first);
    print_student_names(first);

    return 0;
}
Beispiel #2
0
int main(void)
{
	//variable declaration//
	int size,student,row,col;
	float scores[COL_SIZE][COL_SIZE];
	srand(time(NULL));
	//size of array input//
	printf("Enter the size of the array:");
	scanf("%d",&size);
	//error checking//
	while(check_error(size)==0)
	{
		printf("Invalid input enter the size of the array again:");
		scanf("%d",&size);
	}
	//print array//
	printf("\nScores:\n");
	initialize_2Darray(scores,size);
	print_2Darray(scores,size);
	printf("\n");
	//average score// 
	average_scores(scores,size);
	//student number input//
	printf("Enter student number (1-%d):",size);
	scanf("%d",&student);
	//Overal grade for specific student// 
	printf("\nOverall grade for %dth student is %c",student,compute_grade(scores,size,student));
	//input row//
	printf("\nEnter the row (1-%d):",size);
        scanf("%d",&row);
	//input column//
	printf("Enter the col (1-%d):",size);
        scanf("%d",&col);
	//the largest number present in specific row and column//
	printf("The largest number present in row %d or col %d is %.2f\n",row,col,search_max(scores,row,col,size));
	printf("Bonus part");
	printf("\nArray before sorting\n");
	print_2Darray(scores,size);	

}