Write a program that will find the winner in a skating competition. It will have a structure for skater information: name, country, points (array of 10 real numbers), and average. Program will input information of 5 skaters and will find and display the winner by calculating the average point of each skater.
a.) Use function f1() that will receive a skater structure will find and set the average of the skater
b.) Use function f2() that receives array of structures and will find and return the winner skater information to the calling function.
c.) Use function f3() that receives points of a skater and returns its max and min points to the calling function.
in c programming language.
ANSWER :
#source code:
#include <stdio.h>
#include <string.h>
struct skating{
char name[20];
char country[10];
int points[10];
};
int f1(struct skating data[]){
float avg[5];
for(int i=0;i<5;i++){
float sum=0;
for(int j=0;j<10;j++){
sum=sum+data[i].points[j];
}
avg[i]=(float)sum/2;
}
int winner=0;
for(int i=0;i<5;i++){
if(avg[i]>avg[winner]){
winner=i;
}
}
return winner;
}
int f2(struct skating data[]){
return f1(data);
}
void f3(struct skating data[]){
int dataindex=f2(data);
int min=0;
int max=0;
for(int j=0;j<10;j++){
if(data[dataindex].points[j]<data[dataindex].points[min]){
min=j;
}
if(data[dataindex].points[j]>data[dataindex].points[max]){
max=j;
}
}
printf("Winner name:%s\n",data[dataindex].name);
printf("Winner country:%s\n",data[dataindex].country);
printf("max:%d\n",data[dataindex].points[max]);
printf("min:%d\n",data[dataindex].points[min]);
printf("\n");
}
int main(){
struct skating data[5];
float max=0;
for(int i=0;i<5;i++){
scanf("%s",data[i].name);
scanf("%s",data[i].country);
for(int j=0;j<10;j++){
scanf("%d",&data[i].points[j]);
}
}
f3(data);
return 0;
}
SCREEN SHOT OF OUT PUT:

Write a program that will find the winner in a skating competition. It will have a...
c++
Votes received by the candidate. Your program should also output the winner of the election. A sample output is: The Winner of the Election is Duffy. The input data should come from the file. Use 3 separate arrays to store the names, votes, and percentages before they are displayed. Include functions inputValues to input values for candidate names and votes received and place them in arrays. calcPercents which fills an array with the percentage of votes each candidate got....
C++ programming language Write a program that asks the user for a file name. The file contains a series of scores(integers), each written on a separate line. The program should read the contents of the file into an array and then display the following content: 1) The scores in rows of 10 scores and in sorted in descending order. 2) The lowest score in the array 3) The highest score in the array 4) The total number of scores in...
P3 - An Array of objects (120 points) Write a main program and declare an array of 5 RectangularCube objects [20pts). a. Use a loop to initialize an array of RectangularCube. In the body of the loop use the rand () function to generate random integers between 1 and 10 to assign to length, width and height data fields of each RectangularCube object (40pts) b. Write the function with header void printCube (RectangularCube rs) that receives an object of the...
PROGRAMMING LANGUAGE OOP'S WITH C++ Functional Requirements: A jewelry designer friend of mine requires a program to hold information about the gemstones he has in his safe. Offer the jewelry designer the following menu that loops until he chooses option 4. 1. Input a gemstone 2. Search for a gemstone by ID number 3. Display all gemstone information with total value 4. Exit ------------------------------------- Gemstone data: ID number (int > 0, must be unique) Gem Name (string, length < 15)...
Create a program that creates an array of 500 random numbers between -10 and 10. Write several functions: Function 1 - prints the array with a certain number of elements per line. Prototype: void printArray(int array[], int numElements, int numPerLine, ostream &os) Function 2 prints only the array elements that are evenly divisible by an input number. Prototype: void printDivBy(int array[], int numElements, int numPerLine, int divBy, ostream &os) Function 3 takes the input array and returns the maximum, the...
C++ CODE
/* This is program project 2 on page 695.
* Before you begin the project, please read the project description
* on page 695 first.
*
* Author: Your Name
* Version: Dates
*/
#include <iostream>
#include <cmath>
#include <cassert>
using namespace std;
class Fraction
{
public:
// constructor
Fraction(int a, int b);
// generate a fraction which is a/b
Fraction(int a);
// generate a fraction which is a/1
Fraction();
// generate a fraction which is 0/1. i.e...
Need to write a MIPS assembly program that finds the minimum and maximum and sum of a stored array. It also finds the locations of the minimum and maximum. The interaction between the main program and the function is solely through the stack. The function stores $ra immediately after being called and restores $ra before returning to main. The main program reserves a static C like array (index starts from 0) of 10 elements and initializes it. The maximum should...
In C Programming Language, write a program Character Pointers and Functions. Keyboard input to enter one character string. Using a single dimension array, populate the array with the character string, call a function using pointers to reverse order the character string, pass back to the main the output and total_count_of_characters. (maybe use a global variable for the total count). Print display the reversed char string and total_count.
In C Programming Language, write a program Character Pointers and Functions. Keyboard input to enter one character string. Using a single dimension array, populate the array with the character string, call a function using pointers to reverse order the character string, pass back to the main the output and total_count_of_characters. (maybe use a global variable for the total count). Print display the reversed char string and total_count.
Using Atmel studio 7 -C language programming Write a program to find the median of an array of 8-bit unsigned integers. When the array has an even number of elements, the median is defined as the average of the middle two elements. Otherwise, it is defined as the middle element of the array. You need to sort the array in order to find the median. SHOW THAT THE CODE IS WORKING PROPERLY IN ATMEL STUDIO 7