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

Howdy everyone, I have issues with this C Lang assignment and i hope you can hel

ID: 3809121 • Letter: H

Question

Howdy everyone, I have issues with this C Lang assignment and i hope you can help with it.THANK YOU. i'm supposed to change the structure of his code by following these instructions:

*Change the struct card from the attached file (16card.c) to struct class with the following fields:

1-char array called className

2-char array called instructor

3-int called num_credits

4-double my_grade ( ex: 3.5, 4.0)

5-Modify all variable declarations, function prototypes, and functions calls to reflect the changes from card to class

6-For the array of classes use the variable myClasses

*THE CODE BELOW NEEDS TO CHANGE ACCORDLY WITH THE INSTRUCTIONS ABOVE: (:

#define _CRT_SECURE_NO_DEPRECATE
#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 cardcard FillCard();
//fills the data fields of a card instance//by reference using a pointer to a cardvoid FillCardPtr(card *cardptr);
//fills an array of cardsvoid FillCardArray(card arrayC[], int *size);
//displays one cardvoid DisplayCard(card anyCard);
int main(){

//Declare variablescard myCard, myCard1, myCard2;card manyCards[SIZE];int cSize;int i;
//Fill structures with a functionmyCard = FillCard();myCard1 = FillCard();
//print using display functionprintf(" ---------Display myCard ");DisplayCard(myCard);printf(" ---------Display myCard1 ");DisplayCard(myCard1);
//Fill structure using pointers and dispay itFillCardPtr(&myCard2);printf(" ---------Display myCard2 ");DisplayCard(myCard2);
//Fill the array with the functionprintf(" ---------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 cardcard FillCard(){

//Declare local variablescard tempC;//prompt and get informationprintf(" please enter the face of your card: ");scanf("%s", tempC.face);//print to checkprintf("face: %s ", tempC.face);
//prompt and get informationprintf(" please enter the suit of your card: ");scanf("%s", tempC.suit);//print to checkprintf("suit: %s ", tempC.suit);
//prompt and get informationprintf(" please enter the point value of your card: ");scanf("%d", &tempC.pointV);printf("point value: %d ", tempC.pointV);return tempC;

}
//displays one cardvoid 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 cardvoid FillCardPtr(card *cardptr){//prompt and get information

printf(" please enter the face of your card: ");scanf("%s", (*cardptr).face);
//prompt and get informationprintf(" please enter the suit of your card: ");scanf("%s", cardptr->suit);
//prompt and get informationprintf(" please enter the point value of your card: ");scanf("%d", &(*cardptr).pointV);

}

//fills an array of cardsvoid FillCardArray(card arrayC[], int *size){

int i;//prompt the userprintf(" enter the number of cards: ");scanf("%d", size);
//print to checkprintf("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);

}

}

output:

/*please enter the face of your card: kingface: king
please enter the suit of your card: spadesuit: spade
please enter the point value of your card: 10point value: 10
please enter the face of your card: threeface: three
please enter the suit of your card: heartsuit: heart
please enter the point value of your card: 3point value: 3
---------Display myCard
face: kingsuit: spadepoint value: 10
---------Display myCard1
face: threesuit: heartpoint value: 3
please enter the face of your card: king

please enter the suit of your card: diamondsplease enter the point value of your card: 10---------Display myCard2
face: kingsuit: diamondspoint value: 10
---------Fill array manyCards
enter the number of cards: 3size: 3enter face: jackenter suit: clubsenter point value: 10enter face: fourenter suit: heartsenter point value: 4enter face: aceenter suit: spadesenter point value: 11
---------Display array manyCards
face: jacksuit: clubspoint value: 10
face: foursuit: heartspoint value: 4
face: acesuit: spadespoint value: 11Press any key to continue . . .*/

Explanation / Answer

#include<stdio.h>
#include<string.h>

#define SIZE 20

typedef struct
{
char className[SIZE];
char instructor[SIZE];
int num_credits;
double my_grade;
}class;

class FillClass();

void FillClassPtr(class* classptr);

void FillClassArray(class myClasses[] , int * size);

void DisplayClass(class anyClass);

int main()
{

   class myClass, myClass1, myClass2;
   class manyClasses[SIZE];
   int cSize;
   int i;

   myClass = FillClass();
   myClass1 = FillClass();

printf(" ---------Display myClass ");
DisplayClass(myClass);

   printf(" ---------Display myClass1 ");
DisplayClass(myClass1);

FillClassPtr(&myClass2);

printf(" ---------Display myClass2 ");
DisplayClass(myClass2);

printf(" ---------Fill array manyClasses ");
FillClassArray(manyClasses, &cSize);

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

for(i=0; i < cSize; i++){
DisplayClass(manyClasses[i]);
}

return 0;
}


class FillClass()
{
class tempClass;

printf(" please enter the name of your class: ");
scanf("%s", tempClass.className);

printf("Class Name: %s ", tempClass.className);

printf(" please enter the name of the instructor of your class: ");
scanf("%s", tempClass.instructor);
  
printf("Instructor: %s ", tempClass.instructor);

printf(" please enter the credit value of the class: ");
scanf("%d", &tempClass.num_credits);

printf("Num credits: %d ", tempClass.num_credits);
  
printf(" please enter the grades obtained in this class: ");
scanf("%lf", &tempClass.my_grade);

printf("Grades: %lf ", tempClass.my_grade);
  
return tempClass;
}

void DisplayClass(class anyClass)
{
printf(" Class Name: %s ", anyClass.className);
printf("Instructor: %s ", anyClass.instructor);
printf("Num credits: %d ", anyClass.num_credits);
   printf("Grades: %lf ", anyClass.my_grade);
}

void FillClassPtr(class *classptr)
{

printf(" please enter the name of your class: ");
scanf("%s", classptr->className);

printf(" please enter the name of the instructor of your class: ");
scanf("%s", classptr->instructor);


printf(" please enter the credit value of the class: ");
   scanf("%d", &(classptr->num_credits));

   printf(" please enter the grades obtained in this class: ");
   scanf("%lf", &(classptr->my_grade));

}

void FillClassArray(class arrayClass[], int *size)
{
int i = 0;

printf(" Enter the number of classes: ");
scanf("%d", size);

printf("size: %d ", *size);

for (i=0; i < *size; i++){
  
   printf(" Please enter the name of your class: ");
scanf("%s", arrayClass[i].className);

printf(" Please enter the name of the instructor of your class: ");
scanf("%s", arrayClass[i].instructor);

printf(" Please enter the credit value of the class: ");
   scanf("%d", &(arrayClass[i].num_credits));

printf(" Please enter the grades obtained in this class: ");
   scanf("%lf", &(arrayClass[i].my_grade));

}
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote