How to Write a C Program reads in the number of judges and the score from each judge. Then it calculates the average score without regard to the lowest and highest judge score. Finally it prints the results (the highest, the lowest and the final average score).
Solution:
#include <stdio.h> void printInfo(void) { printf("Program information\n"); printf("The program reads in the number of judges and the score from each judge.\n"); printf("Then it calculates the average score without regard to the lowest and\n"); printf("highest judge score. Finally it prints the results (the highest, the\n"); printf("lowest and the final average score).\n"); } int readJudges(void) { int number; while (1) { printf("Number of judges (min 3 and max 10 judges)? "); scanf("%d", &number); if (number >= 3 && number <= 10) { return number; } } return 0; } /*Reads judge scores from user */ void readScore(int number, double judgeScore[]) { printf("\n"); double points; for(int i = 0 ; i < number ; i++) { printf("Score from judge %d? ", i+1); scanf("%lf", &points); judgeScore[i] = points; } } void printScore(int number, double judgeScore[]) { printf("\n"); printf("Loaded scores:\n"); for(int i = 0 ; i < number ; i++) { printf("Judge %d: %.1f\n", i+1, judgeScore[i]); } } /* Returns highest value of 'score' as a pointer */ void highestValue(double* max, int number, double judgeScore[]) { max = judgeScore; for(int i = 0 ; i < number ; i++) { if (judgeScore[i] > *max) { max = judgeScore + i; } } } /* Returns lowest value of 'score' as a pointer */ void lowestValue(double* min, int number, double judgeScore[]) { min = judgeScore; for(int i = 0 ; i < number ; i++) { if (judgeScore[i] < *min) { min = judgeScore + i; } } } void average(int number, double judgeScore[], double* avg, double* min, double* max) { double sum; for(int i = 0 ; i < number ; i++) { sum += judgeScore[i]; } *avg = (sum - *max - *min)/(number - 2); /* Beräknar "medel" utan att ta hänsyn till minsta och största */; } void printResult(double max, double low, double avg) { printf("Final result:\n"); printf("Highest judge score: %.1f\n", max); printf("Lowest judge score: %.1f\n", low); printf("Final average score: %.1f\n", avg); } int main(void) { printInfo(); printf("\n"); int number; number = readJudges(); double score[number]; /* Arrayens storlek beror på readJudges */ readScore(number, score); printScore(number, score); /* Efter readScore exekverats innehåller score alla poäng */ printf("\n"); double avg, low, max; lowestValue(&low, number, score); highestValue(&max, number, score); average(number, score, &avg, &low, &max); printResult(max, low, avg); return 0; }
Learn More :
Average
- C Program Array Example: Average
- Write the procedure , which is one of a sum , a product and a geometric average in the panel for the NxM elements are located on opposite diagonal and main diagonal . Remind ! Counting only odd elements !
- C Program Array NxM Elements Geometric/Arithmetic
- C Program To Find The Average Of n Numbers
- C Program to Average temperature in quarters
- C Program Average Temperature in Quarters
- Average function in C
- C Program to accept n numbers from user store these numbers into an array & calculate average of n numbers
- Accept n number from user, store these number into an array and calculate the average of n number
Read
- Sort Three Numbers - program reads in three Integers and displays them in ascending order.
- C or C++ program to read marks of 4 subjects and find how many students are pass and fail with division
- C Program readers/writers
- C Program to Demonstrates use of reader/writer lock
- C Program to Write/Read Dynamic Data Example
- C Function to read instructions from the file and obey them
- A small I/O bound program to copy N bytes from an input file to an output file.
- Input reads in the array positions and range for random generation.
- C Program to Read and Write FIFO
- pthreads Readers/Writers Lock C Program
- C Program to opens and reads dictionary file specified in spellrc
- C Program reads in and spews out the attributes of a given .wav file.
- Read 10 real numbers using a vector and show the least of them C Program
- C Program To Read A Parenthesised Infix Expression From The User And Check Whether It Is Well Parenthesised Or Not
- C Program To Read The Adjecancy Matrix of Directed Graph And Convert It Into Adjecancy List
- C Program Read a char & print next char ( file to file )
- Menu Driven Program to Read Two Integers Find Sum, Difference and Product C Program
Lowest
Number
- Find out the perfect number using c program
- Write a c program to find out H.C.F. of two numbers.
- Check the given number is armstrong number or not using c program.
- Write a c program to find largest among three numbers using conditional operator
- FIND OUT GENERIC ROOT OF A NUMBER - C PROGRAM.
- FIND PRIME FACTORS OF A NUMBER USING C PROGRAM
- How To Write a C program that generates two random numbers ?
- Write a C program to find maximum or equal between two numbers ?
- How to Write a C program to find maximum between two numbers ?
- Write a C program to perform math operations on two input whole numbers. The operations are:
- Write a C program to find maximum between three numbers ?
- Sort Three Numbers - program reads in three Integers and displays them in ascending order.
- C Program to Enter an ODD number between 1 and 49.
- C program acquires keyboard 10 numbers for each of these numbers to determine if it is a first issue, by printing immediately message should at the end, if none of the numbers you entered was a first issue, print an appropriate message.
- C program generates a random number and uses an algorithm to generate 9 other numbers.
- C Program to Find Random Number
- C Program To Find LCM and HCF Of Two Number Using Function - 2
- C Program to find LCM and HCF Of Two Number Using Recursion - 3
- C Program To Find LCM and HCF Of Two Number -1
- C Program To Find Reverse Of Any Digit Number
- C Program To Find The Frequency Of A Number
- C Program To Print Prime Numbers Upto The Number You Want
- C Program To Print Sum Of n Digit Number
- C Program To Reverse A Number
- C Program To Search A Number Inside The Array
Final
Highest
Score
Calculate
- C Programm zur Berechnung von Umfang und Flächeninhalt verschiedener geomatrischer Figuren
- Napisać funkcję obliczającą funkcję geometryczną w tablicy NxM elementowej z elementów o wartościach parzystych znajdujących się pod główną i ponad przeciwną przekątną.
- C Program to Calculate GCD using recursion
- C Program To Calculate First Numbers Using Recursion
- C Program to Calculation of One Number Raised to Another
- C Program to calculate TT and Recharge Amount
- C Program to Calculate 2 numbers with 1 operation
- Un-sortiertes Array and Sortiertes Array
- C Program Calculation of Simple Interest
- C Program to Calculation of Total and Percentage
- C Program for calculation of Gross Salary
- C Program to calculate Area, Perimeter of Rectangle; Area, Circumference of Circle.
- C program calculates a given function in range given by user, stores the data in arrays and displays the answer in a table.
- C Program for statistically calculating pi using a specific scheduling policy.
- C Program that prompts the user to input a string, (whitespaces allowed)
- C Program to Calculate the mathematical expression for the first n numbers
- C Program to Calculate the price of movie tickets
- C Program to calculate sum of two m*n matrices & store the result in 3 matrix
- C Program to calculate the sum of elements of upper triangle of a n*n matrix using DMA
- C Program to accept n numbers from user store these numbers into an array & calculate average of n numbers
- Calculate sum of element of upper triangle of m*n matrix by using dynamic memory allocation
- Calculate sum of non-diagonal element in m*n matrix C Program
- Accept n number from user, store these number into an array and calculate the average of n number
- Calculate sum of element of lower triangle of m*n matrix by using dynamic memory allocation