302 Exercises 1. What is a record 2 What is a fille 3. What are steps to create
ID: 3594154 • Letter: 3
Question
302 Exercises 1. What is a record 2 What is a fille 3. What are steps to create a record? 4. How do you pass a record to a function 5 Can you pass record to a function by reference? 6. Can you pass record to a function by pointer? 7. Can you have an array of records? Give an example. 8 Can you have a record within another record? Give an example. 9. What is structure tag 10. Given struct Person Declaration of first record string Name / Declaration of second record within first record struct Wage double WH: double Rate double Gross Salary; double Tax; double Net Salary Wage Salary; Suppose "object Steve" is type of person Person Steve; a) How can the object Steve access to the Name field? b) How can the object Steve access to the WH field? c) How can the object Steve access to the Rate Beld? d) How can the object Steve access to the field Salary? e) How can the object Steve access to the field Tax? 0 How can the object Steve access to the field Gross Salary? 8) How can the object Steve access to the field Net_Salary? h) Suppose whl = 50 and Rate = S245. Deduct 23% tax. Calculate the gross salary, tax, and net salaryExplanation / Answer
1. A record is a complete set of information about a person, place or object
2. A file is an object on a computer that stores data, information, settings, or commands used with a computer program
3. The first step is to create a structure or class for the record. After that you can determine the file format. Finally, write each of the functions that add, insert, modify and delete records. Write and test these just one function at a time so that you don't get overwhelmed with the complexity of the program.
4. We can pass a record in a function by passing the structure or a class object by value or by reference.
5. Yes we can pass it by passing pointer to the record.
6. Yes we can pass the pointer.. This is called pass by reference.
7. Array of records is a array of structures or classes. eg Person persons[].
8. Yes we can have a record within a record itself. Its like composition. eg.
Class B{}
Class A{ private: B b}
9. Structure tag is a template of structure without variables.Here variables can be defined later. eg
struct date today, birth_day;
10.
a) We can use it using .operator . Steve.name
b) Steve.Salary.WH
c) Steve.Salary.Rate
d. Steve.Salary
e) Steve.Salary.Tax
f) Steve.Salary.Gross_Salary
g) Steve.Salary.Net_Salary
h)
Steve.Salary.WH = 50;
Steve.Salary.Rate = 24.5;
Steve.Salary.Gross_Salary = Steve.Salary.WH * Steve.Salary.Rate;
Steve.Salary.Tax = 23 *Steve.Salary.Gross_Salary / 100 ;
Steve.Salary.Net_Salary = Steve.Salary.Gross_Salary - Steve.Salary.Tax
11.
a) No its not a valid statement, because = operator is not defined for this.
b) Y.Number = X.Number;
c) Z->Number
d) No. because Z is of type First. So Second address cannot be allocated to First.
e) Z->Number = 35;
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.