my name adriel, new site , programming. anyways need , guidance assignment. create program in c allow user enter 5000 exam scores. give user 5 options average grade, show exams high low, curve exams 5 or down 5 and 1 can't display scores , how many times obtained.
this code:
main() { //declared variables char choice; int i, j, a, n; int examscore = 0, high = 0, low = 0, avg = 0, count = 0, sum = 0, scorecount = 0; int highlow[5000], highexam, lowexam; do{//begin while #1 cls; flush; printf("=========================\n"); printf("===== score program =====\n"); printf("=========================\n"); printf("a. exam scores\n"); printf("b. exams average\n"); printf("c. exam score high - low\n"); printf("d. times scores obtained\n"); printf("e. curved 5 pts\n"); printf("f. curved down 5 pts\n"); printf("q. exit program\n"); printf("=========================\n"); printf("enter choice: "); scanf(" %c", &choice); choice = toupper(choice); switch (choice){//begin switch case 'a': cls; printf("please enter number of exams:\n"); scanf("%d", &n); printf("please enter %d numbers\n", n); (i = 0; < n; i++){ scanf("%d", &highlow[i]); }//end loop highlow[examscore]; count++; sum = sum + examscore; avg = sum / count; highexam = examscore + 5; lowexam = examscore - 5; cls; (i = 0; < n; i++) { (j = + 1; j<n; ++j) { if (highlow[i]<highlow[j]) { = highlow[i]; highlow[i] = highlow[j]; highlow[j] = a; } } } pause; break; case 'b': cls; printf("exam average is: %i\n", avg); pause; break; case 'c': cls; printf("the numbers arranged in descending order given below\n"); (i = 0; < n; ++i) { printf("%i\n", highlow[i]); } pause; break; case 'd': cls; printf("amount of times scored obtained: %i-%i\n", examscore, count); pause; break; case 'e': cls; // printf("exam scores curved 5 pts: %i\n", highexam); pause; break; case 'f': cls; // printf("exam scores curved down 5 pts: %i\n", lowexam); pause; break; case 'q': cls; printf("quitting program. goodbye.\n"); pause; break; default: printf("- invalid entry -\n"); pause; break; }//end switch } while (choice != 'q');//end while #1 }//end main as may see still far done, other parts not big concern me. , advice appreciate.
why difficult count number of times each score in highlow array?
i thinking of different approach until noticed had sorted array of scores, duplicate scores adjacent each other. should easy enough @ value of highlow[0] , compare highlow[1] see if highlow[0] duplicated. until find next isn't duplicate, start looking duplicates of next number.
Comments
Post a Comment