Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

i need to change this with structs the instructions are in the pics #define _CRT_SECURE_NO_WARNINGS #include #include #define SIZE 20 typedef struct{ char face[SIZE]; char

i need to change this with structs
the instructions are in the pics
#define _CRT_SECURE_NO_WARNINGS
#include
#include
#define SIZE 20
typedef struct{
char face[SIZE];
char suit[SIZE];
int pointV;
}card;
//Function Prototypes
// fills the data fields of a card instance
//returns the filled card
card FillCard();
//fills the data fields of a card instance
//by reference using a pointer to a card
void FillCardPtr(card *cardptr);
//fills an array of cards
void FillCardArray(card arrayC[], int *size);
//displays one card
void DisplayCard(card anyCard);
int main()
{
//Declare variables
card myCard, myCard1, myCard2;
card manyCards[SIZE];
int cSize;
int i;
//Fill structures with a function
myCard = FillCard();
myCard1 = FillCard();
//print using display function
printf(" ---------Display myCard ");
DisplayCard(myCard);
printf(" ---------Display myCard1 ");
DisplayCard(myCard1);
//Fill structure using pointers and dispay it
FillCardPtr(&myCard2);
printf(" ---------Display myCard2 ");
DisplayCard(myCard2);
//Fill the array with the function
printf(" ---------Fill array manyCards ");
FillCardArray(manyCards, &cSize);
//display an array of cards
printf(" ---------Display array manyCards ");
for(i=0;i
{
DisplayCard(manyCards[i]);
}
return 0;
}
//Function Definitions
// fills the data fields of a card instance
//returns the filled card
card FillCard()
{
//Declare local variables
card tempC;
//prompt and get information
printf(" please enter the face of your card: ");
scanf("%s", tempC.face);
//print to check
printf("face: %s ", tempC.face);
//prompt and get information
printf(" please enter the suit of your card: ");
scanf("%s", tempC.suit);
//print to check
printf("suit: %s ", tempC.suit);
//prompt and get information
printf(" please enter the point value of your card: ");
scanf("%d", &tempC.pointV);
printf("point value: %d ", tempC.pointV);
return tempC;
}
//displays one card
void DisplayCard(card anyCard)
{
printf(" face: %s ", anyCard.face);
printf("suit: %s ", anyCard.suit);
printf("point value: %d ", anyCard.pointV);
}
//fills the data fields of a card instance
//by reference using a pointer to a card
void FillCardPtr(card *cardptr)
{
//prompt and get information
printf(" please enter the face of your card: ");
scanf("%s", (*cardptr).face);
//prompt and get information
printf(" please enter the suit of your card: ");
scanf("%s", cardptr->suit);
//prompt and get information
printf(" please enter the point value of your card: ");
scanf("%d", &(*cardptr).pointV);
}
//fills an array of cards
void FillCardArray(card arrayC[], int *size)
{
int i;
//prompt the user
printf(" enter the number of cards: ");
scanf("%d", size);
//print to check
printf("size: %d ", *size);
for (i=0; i
{
printf("enter face: ");
scanf("%s", arrayC[i].face);
printf("enter suit: ");
scanf("%s", arrayC[i].suit);
printf("enter point value: ");
scanf("%d", &arrayC[i].pointV);
}
}
/*please enter the face of your card: king
face: king
please enter the suit of your card: spade
suit: spade
please enter the point value of your card: 10
point value: 10
please enter the face of your card: three
face: three
please enter the suit of your card: heart
suit: heart
please enter the point value of your card: 3
point value: 3
---------Display myCard
face: king
suit: spade
point value: 10
---------Display myCard1
face: three
suit: heart
point value: 3
please enter the face of your card: king
please enter the suit of your card: diamonds
please enter the point value of your card: 10
---------Display myCard2
face: king
suit: diamonds
point value: 10
---------Fill array manyCards
enter the number of cards: 3
size: 3
enter face: jack
enter suit: clubs
enter point value: 10
enter face: four
enter suit: hearts
enter point value: 4
enter face: ace
enter suit: spades
enter point value: 11
---------Display array manyCards
face: jack
suit: clubs
point value: 10
face: four
suit: hearts
point value: 4
face: ace
suit: spades
point value: 11
Press any key to continue . . .*/
image text in transcribed
Lab6 Instructions: Your program should: Change the struct card from the attached file (16card.c) to struct course with the following fields: char array className char array instructor int credits double points . char letterGrade Modify all variable declarations, function prototypes, and functions calls to reflect the changes from card to course For the array of courses use the variable myCourses

Step by Step Solution

There are 3 Steps involved in it

Step: 1

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

Decisions Based On Data Analytics For Business Excellence

Authors: Bastian Weber

1st Edition

9358681683, 978-9358681680

More Books

Students also viewed these Databases questions

Question

4. Identify the challenges facing todays organizations

Answered: 1 week ago