Question

In: Computer Science

Create a structure in C called BarcelonaPlayer with the following members. struct BarcelonaPlayer { char name[20];...

Create a structure in C called BarcelonaPlayer with the following members.
struct BarcelonaPlayer
{
char name[20];
int age;
char country[20];
char Position[20];
double Salary;
double Rating;
};
First, create an array of BarcelonaPlayer structures. Now, write a function that takes an array of BarcelonaPlayer structures as input and find out the highest paid player among all the players.
void highestPaidPlayer(struct BarcelonaPlayer *pl, int size);
Create another function that finds all the players from Argentina.
void findPlayers(struct BarcelonaPlayer *pl, int size);

Solutions

Expert Solution

Thanks for the question.
Below is the code you will be needing Let me know if you have any doubts or if you need anything to change.
Thank You!


===========================================================================

#include<stdio.h>
#include<string.h>
struct BarcelonaPlayer
{
char name[20];
int age;
char country[20];
char Position[20];
double Salary;
double Rating;
};

void highestPaidPlayer(struct BarcelonaPlayer *pl, int size){
   int i;
   int highestIndex=0;
   for( i=0;i<size;i++){
       if(((pl+i)->Salary)>((pl+highestIndex)->Salary)){
           highestIndex =i;
          
       }
   }
  
   printf("Player with highest salary is %s",(pl+highestIndex)->name);
}

void findPlayers(struct BarcelonaPlayer *pl, int size){
  
   int i;
   int highestIndex=0;
   for( i=0;i<size;i++){
       if(strcmp((pl+i)->country,"Argentina")==0){
          
           printf("\nPlayer from Argentina: %s",(pl+i)->name);
       }
   }
  
}
int main(){
  
  
   struct BarcelonaPlayer players[]{
       {"Messi",34,"Argentina"," ",4560000,2},{"Ronaldo",34,"Brazil"," ",4560010,4},{"Luiz",34,"Argentina"," ",456010,14},
       {"Griezman",19,"France"," ",14560010,1},{"Ansu",27,"England"," ",5555,14}
   };

   highestPaidPlayer(players,5);
   findPlayers(players,5);
  
}

====================================================================

let me know if you have any doubts or if you need anything to change.

If you are satisfied with the solution, please rate the answer.

Thanks!


===========================================================================


Related Solutions

Implement stack in C Struct: struct patients{ int id; int severity; char *firstName; char *lastName; char...
Implement stack in C Struct: struct patients{ int id; int severity; char *firstName; char *lastName; char *state; int time_spent; }; Given Array: struct patients* patientsArray[4] = {&p1, &p2, &p3, &p4}; Create two functions one for pushing this array to the stack and one for popping the variables such as p1 p2 p3 p4 by its ID
Create a struct for the following groups of data: (a) Product Data with the following members...
Create a struct for the following groups of data: (a) Product Data with the following members • ID • Name • Price • Quantity (b) Customer Data with the following members • ID • Name • Address • E-mail (c) Sales Data with the following members • Customer ID • Product IDs • Sale amount • Choose the types that you think will work best for the above descriptions. • Names should have a maximum size of 50. • Physical...
This project requires the student to create a record (in C++ called a struct). The record...
This project requires the student to create a record (in C++ called a struct). The record should contain several fields of different data types and should allow the user to search the records to find the student with the highest grade. In this project the student should gain an understanding of the nature of records with multiple data types, how to save the records, search the records and retrieve them.  The special problems of maintaining records of multiple data types on...
write a Program in C++ Using a structure (struct) for a timeType, create a program to...
write a Program in C++ Using a structure (struct) for a timeType, create a program to read in 2 times into structures, and call the method addTime, in the format: t3 = addTime(t1, t2); Make sure to use add the code to reset and carry, when adding 2 times. Also, display the resultant time using a function: display(t3);
Name your c++ file Word_LastNameFirstName.cpp. Create a struct that has a word and the length of...
Name your c++ file Word_LastNameFirstName.cpp. Create a struct that has a word and the length of the word. Next, use the struct to store the word read from a text file call “word.txt” and the length of the word. Print out the word x number of times based on the length of the word as shown below. Also, print a statement with the length and determine if the string length has an odd number or even number of characters. You...
In a Package called characterArray, ********JAVA CODE********** 1) Create a char array containing your full name...
In a Package called characterArray, ********JAVA CODE********** 1) Create a char array containing your full name and print it out. 2) Create an uninitialized char array and copy into it      the char array containing your full name and print it out. 3) Create a Character array and copy into it the char array containing      your full name and print it out. 4) Into the Character array, use toUpperCase() to copy the char array containing     your full name...
C++ Project Organization Create a project called Project1 and then name and organize the following programs...
C++ Project Organization Create a project called Project1 and then name and organize the following programs under it. Part 1 CircleArea You are going to write a program to compute and output the area of a circle with a radius of 2.5. Think through what you need to do: Create a variable for radius set it to 2.5 Create a variable for area set it to 3.14159 * radius * radius output the value of area Challenge (not required) Generalize...
In c++, define a class with the name BankAccount and the following members: Data Members: accountBalance:...
In c++, define a class with the name BankAccount and the following members: Data Members: accountBalance: balance held in the account interestRate: annual interest rate. accountID: unique 3 digit account number assigned to each BankAccount object. Use a static data member to generate this unique account number for each BankAccount count: A static data member to track the count of the number of BankAccount objects created. Member Functions void withdraw(double amount): function which withdraws an amount from accountBalance void deposit(double...
You need a data structure that contains fields for name (char array), color (char array), age...
You need a data structure that contains fields for name (char array), color (char array), age (int), and height (int). Name the struct Info when you define it. Create a function named getUserInfo() that asks the user for name, color, age, and height and then returns a data structure containing that information. It should do the following: What is your name? George What is your favorite color? Green What is your age? 111 What is your height in inches? 72...
Below is for C language typedef struct _node { Node *next; char *str; } Node; You...
Below is for C language typedef struct _node { Node *next; char *str; } Node; You are given a function that takes in two Node* pointers to two different linked lists. Each linked list node has a string represented by a character array that is properly null terminated. You're function is supposed to return true if the concatenation of strings in a linked list match each other, else return false. EXAMPLES List 1: "h" -> "el" -> "l" -> "o"...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT