Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

i need help make this program in c no global plz #define _CRT_SECURE_NO_WARNINGS

ID: 3713378 • Letter: I

Question

i need help make this program in c

no global plz

#define _CRT_SECURE_NO_WARNINGS

#include <string.h>

#include <stdio.h>

#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<cSize; 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 < *size; 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 . . .*/

Explanation / Answer

#define _CRT_SECURE_NO_WARNINGS

#include <string.h>

#include <stdio.h>

#define SIZE 25

typedef struct{

char author[SIZE];

char bookName[SIZE];

int pages;

double cost;

}book;

//Function Prototypes

// fills the data fields of a book instance

//returns the filled details of book

book bookDetails();

//fills the data fields of a book instance

//by reference using a pointer to a book

void bookDetailsPtr(book *bookptr);

//fills an array of books

void bookArray(book arrayB[], int *size);

//displays one book

void DisplayBook(book anybook);

int main()

{

//Declare variables

book myBook, myBook1, myBook2;

book bookList[SIZE];

int bSize;

int i;

//Fill structures with a function

myBook = bookDetails();

myBook1 = bookDetails();

//print using display function

printf(" ---------Display myBook ");

DisplayBook(myBook);

printf(" ---------Display myBook1 ");

DisplayBook(myBook1);

//Fill structure using pointers and dispay it

bookDetailsPtr(&myBook2);

printf(" ---------Display myBook2 ");

DisplayBook(myBook2);

//Fill the array with the function

printf(" ---------Fill array Booklist ");

//prompt the user

printf(" enter the number of books: ");

scanf("%d", bSize);

//print to check

printf("Number of books: %d ", bSize);

bookArray(bookList, &bSize);

//display an array of books

printf(" ---------Display array Booklist ");

for(i=0;i<bSize; i++)

{

DisplayBook(bookList[i]);

}

return 0;

}

//Function Definitions

// fills the data fields of a card instance

//returns the filled card

book bookDetails()

{

//Declare local variables

book tempB;

//prompt and get information

printf(" please enter the name of the book: ");

scanf("%s", tempB.bookName);

//print to check

printf("Book Name: %s ", tempB.bookName);

//prompt and get information

printf(" please enter the author of the book: ");

scanf("%s", tempB.author);

//print to check

printf("Author: %s ", tempB.author);

//prompt and get information

printf(" please enter the number of pages of the book : ");

scanf("%d", &tempB.pages);

printf("Number of pages: %d ", tempB.pages);

//prompt and get information

printf(" please enter the cost of the book : ");

scanf("%lf", &tempB.cost);

printf("Cost of the book: %lf ", tempB.cost);

return tempB;

}

//displays one book

void DisplayBook(book anyBook)

{

printf(" Book: %s ", anyBook.bookName);

printf("Author: %s ", anyBook.author);

printf("Number of pages: %d ", anyBook.pages);

printf("Cost of the book: %lf ", anyBook.cost);

}

//fills the data fields of a book instance

//by reference using a pointer to a book

void bookDetailsPtr(book *bookptr)

{

//prompt and get information

printf(" please enter the name of the book: ");

scanf("%s", (*bookptr).bookName);

//prompt and get information

printf(" please enter the author of the book: ");

scanf("%s", bookptr->author);

//prompt and get information

printf(" please enter the number of pages of the book : ");

scanf("%d", &(*bookptr).pages);

//prompt and get information

printf(" please enter the cost of the book : ");

scanf("%lf", &(*bookptr).cost);

}

//fills an array of cards

void bookArray(book arrayB[], int *size)

{

int i;

for (i=0; i < *size; i++)

{

printf("enter Book name: ");

scanf("%s", arrayB[i].bookName);

printf("enter author name: ");

scanf("%s", arrayB[i].author);

printf("enter number of pages: ");

scanf("%d", &arrayB[i].pages);

printf("Enter the cost of the book: ");

scanf("%lf", &arrayB[i].cost);

}

}