Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Create a structure named player with the following components and appropriate data types: name , age , country , rank . I. Create an array

Create a structure named player with the following components and appropriate data types: name, age, country, rank.

I. Create an array of players P, of size n (from input) and take input to fill the array.

II. Now take input of a player’s name. Search the whole array and print the corresponding age, country and rank if the name is found. Print “not found” otherwise.

Input Format

The first line of input contains an integer N denoting the number of player structures to be included in the array. The next line is empty. Each of the next N blank-line separated blocks of 4 lines contains - name, an integer A denoting age, country, and an integer R denoting rank (which can be 0 if no official ranking exists for the sport) - in the following format:

name A country R

The last line of input contains the name of the player which is to be searched in the array.

Constraints

1 ≤ N ≤ 10

10 ≤ A ≤ 50

0 ≤ R ≤ 100

Note: You will face a problem on HackerRank or other IDE while taking a string as input. To take a string with whitespace, you can select any of the following code:

If the string is:

char name[30];

you can write:

scanf("");gets(name);

OR

scanf("");scanf("%[^]%*c", name);

OR

scanf("");scanf("%[^]", name);

Output Format

Print the name, age, country and ranking, each in a separate line (as shown below), of the player whose name has been given as input. If the name is not found in the array, print "Player Not Found" without the double-quotes.

printf("Namet: %sAget: %dCountryt: %sRankingt: %d",P[i].Name,P[i].Age,P[i].Country,P[i].Ranking);

Sample Input 0

2Lionel Messi32Argentina2Cristiano Ronaldo35Portugal1Lionel Messi

Sample Output 0

Name    : Lionel MessiAge    : 32Country    : ArgentinaRanking    : 2

Sample Input 1

5a10b10a20b20a30b30a40b40a50b100Messi

Sample Output 1

Player Not Found

Week 08 - Task 02 - Structure Find the Player Problem Submissions Discussions Create a structure named player with the following components and appropriate data types: name, age, country, rank. 1. Create an array of players P, of size n (from input) and take input to fill the array. II. Now take input of a players name. Search the whole array and print the corresponding age, country and rank if the name is found. Print "not found" otherwise. Input Format The first line of input contains an integer N denoting the number of player structures to be included in the array. The next line is empty. Each of the next N blank-line separated blocks of 4 lines contains - name, an integer A denoting age, country, and an integer Rdenoting rank (which can be O if no official ranking exists for the sport) - in the following format: name A country R The last line of input contains the name of the player which is to be searched in the array. Constraints 1SNS 10 10 SAS 50 OS Rs 100 Note: You will face a problem on HackerRank or other IDE while taking a string as input. To take a string with whitespace, you can select any of the following code: If the string is: char name[30]: you can write: scanf(""); gets (name); OR scanf (""); scanf ("[A]rc", name) OR scanf (""); scanf("S[*}", name);

Step by Step Solution

3.41 Rating (154 Votes )

There are 3 Steps involved in it

Step: 1

Here is the required code implemented in C having Complete Working Code with comments Sample inputs and outputs Step by step explanations of working o... blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Elements of Electromagnetics

Authors: Matthew

3rd Edition

019513477X, 978-0195134773

More Books

Students also viewed these Programming questions

Question

Explain all drawbacks of the application procedure.

Answered: 1 week ago