Question

Create a program which uses each struct declared in problem 1 and accesses each member of...

Create a program which uses each struct declared in problem 1 and accesses each member of each struct. (a) Create a variable using each struct and initialize it with some mock data of your choosing. (b) Print the members of each struct separated by a newline. (c) Modify each member of each struct to something different. (d) Print all members again. Save your code as prob2.c.

This is Problem 1:

struct ProductData

{

    int ID;

    char Name[50];

    float Price;

    int Quantity;

};

struct CustomerData

{

    int ID;

    char name[50],Address[100];

    string Email;

};

struct SalesData

{

    long ID,ProductID;

    long salseamount;

    char name[50],Address[100];

    string Email[40];

};

a) product data with the following members...

struct ProductData

{

    int ID;

    char Name[50];

    float Price;

    int Quantity;

};

b) Customer Data with the following members...

struct CustomerData

{

    int ID;

    char name[50],Address[100];

    string Email;

};

c)Sales Data with the following members...

struct SalesData

{

    long ID,ProductID;

    long salseamount;

    char name[50],Address[100];

    string Email[40];

};

Homework Answers

Answer #1

The below-Mentioned Code is in C++;

#include<bits/stdc++.h>

using namespace std;

//just defining of all three structures

struct ProductData

{ int ID;

char Name[50];

float Price;

int Quantity;

};

struct CustomerData

{ int ID;

char name[50],Address[100];

string Email;

};

struct SalesData

{ long ID,ProductID;

long salseamount;

char name[50],Address[100];

string Email[40];

};

int main()

{

ProductData p; // initialize and creating  of Product Data Structures  //assigning the demo values

p.ID=1; //assigning the demo values

p.Price=12,p.Quantity=12;

char x[50]={'R','A','V','I'};

for(int i=0;i<4;i++)

{

p.Name[i]=x[i];

}

cout<<p.ID<<" "<<p.Name<<" "<<p.Price<<" "<<p.Quantity<<"\n";

CustomerData c; // initialize and creating  of Product Data Structures

c.ID=2,c.Email="122";    //assigning the demo values

char y[50]={'A','V','I'};

for(int i=0;i<3;i++)

{

c.name[i]=y[i];

}

char v[50]={'1',' ','s','t','r','e','e','t'};

for(int i=0;i<8;i++)

{

c.Address[i]=v[i];

}

cout<<c.ID<<" "<<c.Email<<" "<<c.name<<" "<<c.Address<<"\n";

SalesData s;// initialize and creating  of Product Data Structures  

s.ID=3,s.ProductID=12,s.salseamount=1234; //assigning the demo values

for(int i=0;i<3;i++)

{

s.name[i]=c.name[i];

}

for(int i=0;i<8;i++)

{

s.Address[i]=c.Address[i]; // (c)Modifying is done by this method so Modifying

}

cout<<s.ID<<" "<<s.ProductID<<" "<<s.salseamount<<" "<<s.name<<" "<<s.Address;

}

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
C++ program that Create a struct called car that has the following data members (variables): -...
C++ program that Create a struct called car that has the following data members (variables): - Color //color of the car - Model //model name of the car - Year //year the car was made - isElectric //whether the car is electric (true) or not (false) - topSpeed //top speed of the car, can be a decimal. code i have done struct not working properly. #include <iostream> using namespace std; struct Car { string color; string model_number; int year_model; bool...
In the following C code, Which variable if NOT of primitive data type? A. a B....
In the following C code, Which variable if NOT of primitive data type? A. a B. b C. c D. d int a = 10; double b = 20.0; float c = false; char d[5] = "Hello"; // here we define a string In programming language C, the implementation of a string data type is limited dynamic length, which means the length of a string variable is fixed once it has been defined. A. True B. False In C# programming...
Only use C for this problem. To start, create a structure with arrays. Any structure you...
Only use C for this problem. To start, create a structure with arrays. Any structure you decide on is ok, just create your own. That said, you are required to meet these guidelines: 1. You must give the structure you make a name. Any is ok 2. Your structure must have at least 3 members. 3. Two of those members must be arrays. 4. Your members need to be of at least two different data-types. To clarify, your members cannot...
In C++ Employee Class Write a class named Employee (see definition below), create an array of...
In C++ Employee Class Write a class named Employee (see definition below), create an array of Employee objects, and process the array using three functions. In main create an array of 100 Employee objects using the default constructor. The program will repeatedly execute four menu items selected by the user, in main: 1) in a function, store in the array of Employee objects the user-entered data shown below (but program to allow an unknown number of objects to be stored,...
Question 1 Which statement is false about what Data Types defines Question 1 options: What values...
Question 1 Which statement is false about what Data Types defines Question 1 options: What values a variable cannot hold? How much memory will be reserved for the variable? What value a variable will hold? How the program will use the data type? Question 2 Using the structure below, which of the following statements about creating an array (size 20) of structures are not true? struct Employee{     string emp_id;     string emp_name;     string emp_sex; }; Question 2 options:...
Getting the following errors: Error 1 error C2436: '{ctor}' : member function or nested class in...
Getting the following errors: Error 1 error C2436: '{ctor}' : member function or nested class in constructor initializer list on line 565 Error 2 error C2436: '{ctor}' : member function or nested class in constructor initializer list on line 761 I need this code to COMPILE and RUN, but I cannot get rid of this error. Please Help!! #include #include #include #include using namespace std; enum contactGroupType {// used in extPersonType FAMILY, FRIEND, BUSINESS, UNFILLED }; class addressType { private:...
currently the code contacts the server 1 time and exits. Modify the code so that the...
currently the code contacts the server 1 time and exits. Modify the code so that the program contacts the server five times before exiting. /* client.c - code for example client program that uses TCP */ #ifndef unix #define WIN32 #include <windows.h> #include <winsock.h> #else #define closesocket close #include <sys/types.h> #include <sys/socket.h> #include <netinet/in.h> #include <arpa/inet.h> #include <netdb.h> #endif #include <stdio.h> #include <string.h> #include <stdlib.h> #include <unistd.h> #define PROTOPORT 5193 /* default protocol port number */ extern int errno; char...
In this assignment, you’ll make an inventory system for a store’s items, including produce and books....
In this assignment, you’ll make an inventory system for a store’s items, including produce and books. The starter program is an inventory system for only produce. 1. Include the price of an item by adding to the Item class the protected data member int priceInDollars that stores the price in dollars of an individual item. Write a public function SetPrice with a single int parameter prcInDllrs and returns nothing. SetPrice assigns the value of prcInDllrs to priceInDollars. Modify the AddItemToInventory...
For a C program hangman game: Create the function int setup_game [int setup_game ( Game *g,...
For a C program hangman game: Create the function int setup_game [int setup_game ( Game *g, char wordlist[][MAX_WORD_LENGTH], int numwords)] for a C program hangman game. (The existing code for other functions and the program is below, along with what the function needs to do) What int setup_game needs to do setup_game() does exactly what the name suggests. It sets up a new game of hangman. This means that it picks a random word from the supplied wordlist array and...
For this assignment, you need to submit a Python program that gathers the following employee information...
For this assignment, you need to submit a Python program that gathers the following employee information according to the rules provided: Employee ID (this is required, and must be a number that is 7 or less digits long) Employee Name (this is required, and must be comprised of primarily upper and lower case letters. Spaces, the ' and - character are all allowed as well. Employee Email Address (this is required, and must be comprised of primarily of alphanumeric characters....
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT
Active Questions
  • Identify a true statement about prelinguistic vocalizations. A. Babbling is not inborn. B. Deaf children cannot...
    asked 1 minute ago
  • write a note summarizing the evidence for and against expansionary fiscal policy causing higher GDP growth...
    asked 2 minutes ago
  • please show all work In order to estimate the mean amount of time computer users spend...
    asked 11 minutes ago
  • There is natural conflicct in radilogy between providing high subject contrast for image formation and kepping...
    asked 46 minutes ago
  • Marni is 31 years old and 35 weeks pregnant. She was initially seen in the emergency...
    asked 1 hour ago
  • When designing a network of distribution centers to serve a large market, like the U.S., it...
    asked 1 hour ago
  • 1. According to psycholinguistic theory, _____ . A. language acquisition devices hinder the process of language...
    asked 1 hour ago
  • Following are selected accounts for Mergaronite Company and Hill, Inc., as of December 31, 2018. Several...
    asked 2 hours ago
  • Should welfare recipients be required to work? If so, what should happen to their children while...
    asked 2 hours ago
  • Calculate the concentrations of all species in a 0.580 M Na2SO3 (sodium sulfite) solution. The ionization...
    asked 2 hours ago
  • 1. A(n) _____ is an example of Simple Harmonic Motion. ticking wrist-watch oscillating mass on a...
    asked 2 hours ago
  • Year Stock Price 2014 $         22.25 2015 $         22.50 2016 $         22.00 2017 $   &nbsp
    asked 2 hours ago