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

Question# 1) Define a Date structure with three integer variables day, month and

ID: 3716405 • Letter: Q

Question

Question# 1)

Define a Date structure with three integer variables day, month and year. Define the constructor with three input parameters. Create a variable named birthday with day 23, month 8, and year 1983

Question# 2)

struct Costs {

                        double wholesale;

                        double retail; };

struct Item {

                        string PartNum;

                        string description;

                        Cost pricing };

i.Write the instructions that define a variable type Item named product1. Write the instructions that set the PartNum to “345ZZ”, description to “door nob”, wholesale pricing to 100.0 and retail pricing to 150.0.

ii. Draw the prudoct1 record to illustrate its members.

Explanation / Answer

Answer1

#include <stdio.h>

struct dateStr{
int day;
int month;
int year;
};
int main()
{
  
struct dateStr date={.day=23,.month=8,.year=1983};
  
printf("%d-%d-%d",date.day,date.month,date.year);

return 0;
}

Answer2.

#include <stdio.h>

struct Costs {

double wholesale;

double retail; };

struct Item {

char PartNum[50];

char description[50];

struct Costs pricing; };
int main()
{
  
struct Item product1={.PartNum="345ZZ",.description="door nob",.pricing.wholesale=100,.pricing.retail=150};
  
printf("PartNum - %s Description - %s Wholesale Price = %f Retail Price = %f",product1.PartNum,product1.description,product1.pricing.wholesale,product1.pricing.retail);

return 0;
}

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