Question
C Programming // use stdio.h, stdlib.h, string.h and math.h only. Write a program that use a structure type player_t to store information about a Cricket
C Programming // use stdio.h, stdlib.h, string.h and math.h only.
Write a program that use a structure type player_t to store information about a Cricket player. You should store the following fields (no more, no less).
letter - a char representing the first letter of the player's name
age - an int field to store the age of the player
avg - a double field to store the batting average of the player
At this stage the program should only define the structure type player_t and declare a player_t type variable called player. Understand the distinct differences/similarities between struct player , player_t and player.
NOTE: Be careful, pay attention to where in the program you should define player_t and player. You should avoid using global variables.
2- Write function that reads the corresponding fields from the user and return a the player's information in structure form. Use the prototype:
player_t scanPlayer (void);
Sample output when running this function would be:
Enter the first letter of the player name> B Enter the age> 40 Enter the batting average> 99.941908
Also write a function that prints the content of a structure type player_t. Use the prototype:
void printPlayer (player_t p);
Sample output when running this function would be (notice the rounding of batting average when printing):
B 40 99.94
Use these two functions in your main program to scan, store and print the variable player.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started